Vetrix AI

Upload your latest creations here.
Please note that by posting comments to posts in this forum you forfeit your personal copyright on whatever you post. AI Scripters reserves the right to re-use objective comments in script reviews without requiring the posting author's permission. Credit, where appropriate will be given in such cases.
Post Reply
User avatar
Promiskuitiv
Waheguru
Posts: 1364
Joined: Thu Nov 10, 2011 1:07 pm

Re: Vetrix AI

Post by Promiskuitiv »

About the skirmisher issue:

1) Well the only time your AI ever sets the can-train-skirm goal which is required for skirms to be trained (in your AI) to no is when

Code: Select all

    (goal transition-time gv-yes)
    (not(town-under-attack))
is true. After taking a short look through your AI (set-goal transition-time gv-yes) only fires once in a (disable-self) rule when your AI decides to escrow for the imperial-age research. So the time-period (until the transition-time goal is back to "no" again - which is when you click imp) is very short. If the can-train-skirm goal wasn't meant to control skirmisher training anyway (and was just meant to help saving up resources for imp) then forget about this and continue reading 2).

2) The other condition is having the SN g-train-skirms to contain a value of at least 1. The only time your AI ever sets that SN to 0 is right at the start of the script. So your AI only needs it to set it to a value of 1 or higher once and after that it will never go back to 0 since your AI is missing a rule that checks if the enemy doesn't have archers at all (in which case the AI should set the SN to 0 again). To solve this you could also simply set strategic-number tg-archers to 0 in a (true) rule without a (disable-self) at the start of your script. It would then be set to 1+ in your other rules again if the enemy has archers (so it will remain 0 if the enemy doesn't have archers and your AI won't train skirmishers).

You could also implement a maximum amount of skirmishers to be trained if the value of that SN is 1, a higher maximum amount if the goal is 2, same for 3 etc. Or just use one maximum amount in total. You pretty much never want an army consisting only out of skirmishers. If you have 80 skirmishers and reached the pop cap you won't be able to do any real damage with these units (on the offense) while you're also prone to being overrun by enemy cavalry (if the enemy scouts that you have so many (and only) skirmishers then he will most likely just go for cavalry, siege units or even heavy infantry).

I hope that helps!
Funnily enough i had the same issue when i started scripting (i had a rule somewhere that trained skirmishers pretty much non-stop and it took me a while to find it).

User avatar
THE RULER
Guru
Posts: 655
Joined: Sat Feb 20, 2010 10:55 am
Location: FRG
Contact:

Re: Vetrix AI

Post by THE RULER »

there's boarhunting code available in may Ais- copy them and add a note for the source. least code to worry about.

resources are limited

wood: either buildings, units
food: either villis or units
gold: either units or market
stone: nasty castle ? tower rush !

and all three additional .. or research

it's the art of the scripter now get it work as desired. always with compromisses and in focus of your strat.

basically the Ai is a bad defender, the 1st attacker wins, unlike you have perfect counters or superiority (also in civ) or luck.
that's the secret of all upclass Ais like ATE, Horde or in perfection Barby (and some more of course),all devil aggressive.

IMO start with one civ ( I've preferred viks, free carts), code a flush and nothing else, use a goal to switch that off.
optimize Eco and speed up to feudal age, compare it with Ais that strat you like to track. ( quit the game after a certain time and compare on the eco table).
if feudal age time is ok and no lack in resources, then go on in feudal 1st 3 minutes and compare again.
develope furtheron, setting stop points and compare.

takes time mate, boring a bit, but Barby wasn't scripted within few days.

scripting is a passion, time is no issue.

Have fun, our cummunity honour any script(er), winning or not ( as long as they are in polite behaviour, I guess)

Oh: split your AI into files just from the beginning, better overlook ! difficult to do it later.

BTW: simple TSA in UP: (defconst enemy-min-dist 215) initial value 50 tiles ( or after complete retreat)

(defrule
(goal TSA on)
=>
(up-modify-sn sn-maximum-town-size s:= enemy-min-dist)
)
(defrule
(goal TSA on)
(strategic-number sn-maximum-town-size < 50)
(up-enemy-buildings-in-town == 0)
=>
(up-modify-sn sn-maximum-town-size c:+ 2)
(up-modify-sn enemy-min-dist s:= sn-maximum-town-size)
(up-chat-data-to-self "TSA: %d." s: sn-maximum-town-size)

)
(defrule
(goal TSA on)
(strategic-number sn-maximum-town-size >= 50)
(strategic-number sn-maximum-town-size < 125)
(not(enemy-buildings-in-town))
=>
(up-modify-sn sn-maximum-town-size c:+ 1)
(up-modify-sn enemy-min-dist s:= sn-maximum-town-size)
(up-chat-data-to-self "TSA: %d." s: sn-maximum-town-size)

)

TSA over 100 : your units will get lost in space lol
It's poison and it's blood and big fire, big burn - into the ashes and no return

User avatar
KiiNgZoNe
Forumer
Posts: 62
Joined: Fri Mar 02, 2012 8:15 am

Re: Vetrix AI

Post by KiiNgZoNe »

I'm about to upload a new update after I make some fixes.

I have a problem that the AI builds mining camps all over its town. I think it starts to happen during late castle age.

I have another problem regarding the food gatherers. After they hunted all 2 boars, they will hunt deer. After that, they keep retasking themselves to oblivion, causing them to run around needlessly, and drop only about less than 5 food.

After uploading the update, I would also like to look into the "OTHER ATTACK RULES". The attack-groups do not trigger even with the requirements met, even if I don't restrict it if TSA is ever going to be on. In fact I tried to mix it with TSA but sometimes it doesn't seem to work. The AI will only attack during the feudal-castle transition.

User avatar
THE RULER
Guru
Posts: 655
Joined: Sat Feb 20, 2010 10:55 am
Location: FRG
Contact:

Re: Vetrix AI

Post by THE RULER »

1. still too early on farms, so too early on wood cutters - take the meat and berries,and start at the ~7th minute with farms
2. go heavy on food up to 9th minute and swap to wood during transition to feudal ( 4 to 6 farms is enough in DA)
3. you want to do all at the same time - sry that's selfdestroying !
4. archers only sucks in feudal as offensive units, eat all your wood and need goldminers who are needed for food and wood.
5. I still do not know what intension this script has :blink:
even for a med CA time ( 22min) you can't do that when ordering all feudal researches ( min requirements: axe, fletching or collar, some take the cart instead if well on food)
6. attgrps are difficult to handle, UP has better commands like up-target-point.
7: ranged units and att grps won't work, with ranged units you should prefer TSA, that keeps the group gathered ahead enemy camp.

either you prepare for a flush ( even defensive) or you go FC ( maybe with a minium of unit training)
if you go FC you can't train villis in feudal except not more than about 3; if you arrive in feudal you may get a food plus of about 400 to 550 with a 28 pop.
with a 31 pop you may get 600 on food, needs about 9 to 11 farms (DA , up to 18 in FEUDAL, ref Arabia) then arriving ~14th minute.
so if you take your storage for villis (50 each) and researches, you have nothing left and will never be able to fill it up in less 28 min.
In 30 min a good FC script can churn out to >100 pop ! (very best I'll ever saw was 110 pop)

for a flush you can mix some archers, when low on food, but only archer army :huh:

have fun, don't give up
It's poison and it's blood and big fire, big burn - into the ashes and no return

User avatar
KiiNgZoNe
Forumer
Posts: 62
Joined: Fri Mar 02, 2012 8:15 am

Re: Vetrix AI

Post by KiiNgZoNe »

THE RULER wrote:1. still too early on farms, so too early on wood cutters - take the meat and berries,and start at the ~7th minute with farms
2. go heavy on food up to 9th minute and swap to wood during transition to feudal ( 4 to 6 farms is enough in DA)
3. you want to do all at the same time - sry that's selfdestroying !
4. archers only sucks in feudal as offensive units, eat all your wood and need goldminers who are needed for food and wood.
5. I still do not know what intension this script has :blink:
even for a med CA time ( 22min) you can't do that when ordering all feudal researches ( min requirements: axe, fletching or collar, some take the cart instead if well on food)
6. attgrps are difficult to handle, UP has better commands like up-target-point.
7: ranged units and att grps won't work, with ranged units you should prefer TSA, that keeps the group gathered ahead enemy camp.

either you prepare for a flush ( even defensive) or you go FC ( maybe with a minium of unit training)
if you go FC you can't train villis in feudal except not more than about 3; if you arrive in feudal you may get a food plus of about 400 to 550 with a 28 pop.
with a 31 pop you may get 600 on food, needs about 9 to 11 farms (DA , up to 18 in FEUDAL, ref Arabia) then arriving ~14th minute.
so if you take your storage for villis (50 each) and researches, you have nothing left and will never be able to fill it up in less 28 min.
In 30 min a good FC script can churn out to >100 pop ! (very best I'll ever saw was 110 pop)

for a flush you can mix some archers, when low on food, but only archer army :huh:

have fun, don't give up
Thanks!

1. Yep, it's about time I fix this AIs farming. Controlling them after dark age becomes a hassle.
2. I see. I realized I had put it way before to like 15 lol. That answers the question why it doesn't really have much wood to save when it hits feudal :rofl
3. What do you mean by this? I don't know, but what I think is that I try to grind the AI's microing 'till it hurts. That's probably the reason why I never get higher amount of resources until it has worn-out, tech-wise and pop-wise. I do this because I race against others to make an efficient army then attack as quick as possible, as much as possible, be the first one to attack massively.

4. I know. I am working my way to make those archers harrass the enemy. Archer flushes were meant to harrass the eco anyway.
5. Macromanagement is still a problem with this AI, eco-wise. I constantly polish, add or subtract, and if there are faults, rinse and repeat. I'd like to have this AI do a common style which just harrasses enemy eco until it can mass an army for a steamroll.

6. Is that one of those which involves DUC commands (I don't even know those really quite actually) ? I've yet to orient myself to those and start, but for now, I keep working on the AI's common necessities to make it as stable as possible while maintaining its simplicity. (I want to make this AI as one of the simplest but better as well.)

7. Thanks! I'll look into that. I'm gonna try a playaround with this like mixing TSA with attack-now on ranged units. (just curiosity lol)

Thanks for the tips! More reviews, more opportunities to work on to! I constantly fix and test my AI that I even lose track of time I even get as far as 2am :rofl

User avatar
marathon
Waheguru
Posts: 1984
Joined: Fri May 14, 2010 2:30 pm

Re: Vetrix AI

Post by marathon »

lol, please don't use attack-now. It is laggy. Sure it is strong, but only because it freezes enemy units.
You can mix or alternate between TSA and attack-groups. There are various solutions for TSA, it is enlighting to play with some parameters like:
- Once your TS reaches your enemy buildings, will you increase for a further few tiles or not?
- sn-gather-defend-soldiers
- sn-sentry-distance

also that setting that ignores enemy camps.

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Vetrix AI

Post by Campeador »

"3. you want to do all at the same time - sry that's selfdestroying !"

Ruler means that if you try to improve too many types of units you'll have an army with a high diversity, but with less upgraded units than your enemies. I remember than the first versions of my Crusade castled at 35-38' because they used m@a, spears if enemy cav, archers, skirms if enemy archers, and scouts. So many upgrades and so many buildings spamming expensive units delayed my castle advance to much.

The funny thing is that our mate Jdstankovsky, my main rival when I was starting to script, did the opposite way: really minimalistic AIs like SRN doing KLEW, Tlamacaqui with monk rushes o another one with ony Celt scorpions. His AIs advanced really fast and they were always dangerous scripts even if you trained their counters.

Most competitive AIs do something in the middle but nearer to his aproach. They train the least types of soldiers as possible, but preparing plans B in case they detect they are completely countered. Trying that plans B are also so minimalistic as possible.

User avatar
KiiNgZoNe
Forumer
Posts: 62
Joined: Fri Mar 02, 2012 8:15 am

Re: Vetrix AI

Post by KiiNgZoNe »

Oh. I see. Thanks for enlightening me! Now I know, that I need a better solution to advance better, then. The actual reason that I would only use archers in the Feudal Age, is to make me advance faster. I've yet to come to a plan to halt the other upgrades other than them, then slowly progress the upgrades while focusing my AI on its unit goal. The "primary and secondary" thingy was inspired by ATE and The Duke, and I placed a tertiary unit for emergency purposes, because I remember lessening the diversity of my units, by using a "unit-goal". It was so cool especially with xbows, but were stomped before trying to get to imperial age when it had rams coming their way, even with a plan B on the script. For now I'm working my way to meet that suggestion of yours, Campeador. Thanks!

I have these problems in attacking:

For the flush and crush purposes, the attack-groups don't really work at all when I tested it. It SHOULD trigger when Vetrix have 8 or more units, and retreat with less than 7 units. Even when it had 17 archers on its arsenal, it never attacked so Vetrix's supposed-to-be-usual-strategy in feudal age never met its purpose, to harrass eco. The TSA works really well in 1v1, but the attack priorities weren't met, maybe, seldom. Sometimes I don't care, sometimes I do, because it never meet my AI's purpose, like attacking a barracks with archers to submission instead of finding a lumber camp and kill villagers. At team games, it doesn't really make the AI target its "target", though I usually don't care especially in 3v3 because of 2v1-ing, but it's sometimes a deal especially for raiding and harrassing purposes.

What I want for Vetrix to be is an eco-raiding AI, then go for the coup de grace with a steamroll of units (siege, and whatever necessary to crumble an enemy base). At the moment it doesn't meet its purpose hehehe :head :rofl

Archon
Waheguru
Posts: 1905
Joined: Sat Nov 08, 2003 9:22 am

Re: Vetrix AI

Post by Archon »

Mining camps all over the place: You should cap them. Arabia has a big, a small and a far gold pile per player and two stone piles. So five mining camps are suffice until you later want to fight over neutral resources. Some issues with the mining camp placements:
- The three far gold piles get ignored by the game engine, even when within the camp max distance and camps become placed into nowhere. No idea how to fix that.
- building or map obstacles prevent a placement next to a gold site. Use a big dropsite-min-distance, even if that means long walking distances from a bad camp. Dropping additional camps or your TC before your main gold pile is exhausted may prevent building something next to gold/stone.
- neutral or far gold pile are contested by the enemy. Don't build camps if you detect dead miners. Also use sn-defer-dropsite-update if you haven't already.

Archers: I disagree with RULER's point 4. Archers are really cheap considering wood and gold are easier to gather in feudal age compared to food. But you may want a wood buffer so you don't run out of farms.

Attack groups: Yeah, sometimes even with UP commands they don't reset properly in my script. But I still think they're a better choice than TSA (less scattering is good), unless your enemy has mangonels or scorpions. Using DUC to send your attack is even better, but harder requires more work from the scripter.

Your attack problem: If you have < 7 military you loop enable-timer 1 1, even when not attacking. Later when you want to attack, you immediately disable the attack because you still have timer 1 triggering. :head

User avatar
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Re: Vetrix AI

Post by Campeador »

Archers. My Crusade started being a Saracen AI, but Cruzada, my next AI in a long future, will start being a Mayan AI because archer flushes are easy to script, for the same reasons that you have mentioned. I also remember that when my Crusade chosed an archer flush strat it advances faster to castle than other flushes.

Anyway, as every strat in the game, it has weaknesses. In this case to skirms, towers and eagles. So a super AI needs to be prepared to add other units or even replace archers by them. Or not. For example massed archers can defeat even towers or eagles, and xbow upgrade is easier to get than eskirm. This is one of the reasons because AI problems have multiple possible solutions, and often yoou can't say that there is a way "better" than the rest.


Counters. To design a good counter system, apart from ATE and The Duke you also can consider other AIs with good ones, like The Horde, Crusade or CPS_Alexander. Although my Cruzada will have a different one. For example Crusade sets a threat level depending of the number of units of a dangerous type, and creates a number of counterunits depending of that threat level. But instead of number of units, I'll try for Cruzada a system to count percentages of units. For example I could add spears if 33% of enemy soliders are cavalry or remove archers if 50% are cavalry or skirms.


I'm sure that my new system will have also problems, it's just a thing to design something that you think that can work and fit your AI, implement, test, change or not, optimize, retest, etc.


Atk-groups. The best ways to attack were TSA and atk-groups. TSA allows less suicidal atacks against the nearest building, while atk-groups allowed well grouped units but more suicidal behavior. Currently the best ways are TSA using a few new UP sns or DUC commands, which allow something like atk-groups but better. Ig nore if you still need boat-atack-groups to land soldiers in island maps or you can do it just with DUC.

You can find more info in the threads of the AI section of AoKH forums. For example this:

http://aok.heavengames.com/cgi-bin/foru ... ,40946,,30

Post Reply