Crusade AI Project

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
Campeador
Waheguru
Posts: 1340
Joined: Mon Nov 01, 2010 8:11 am
Location: Spain

Crusade AI Project

Post by Campeador »

I present you Crusade project, my future AI. I’m speaking a “little” about it to receive your conseil and learn about to improve it as maximum.

I want Crusade serves for every civ and setting, but at first it I’m designing its strategies for Saracen civ, because they are a generalist civ and most strategies for them will be useful for others. Always thinking in RM but adding rules that allow more military buildings or faster age advancement if we have tons of resources (DM games or perhaps a few scenarios). When I had created strategies for every civ in Arabia, I'll make strategies for more defensive maps, team games and finally for water maps. Supposing I'm not tired with Arabia, because I haven't got a lot of time and you know better than me that this is an exhausting hobbie. B)

At this moment I've made the files for constants and the dark age (prepared to function even in non-dark-age-starting thanks to the goal G-INITIAL-AGE).

Well, at first was greatly impressed because surprisingly my AI seemed arrive to Feudal Age in 13:40 (14 villagers and loom researched with NO idle Town Center except the last seconds building first house). Of course with an economy too weak to flush. But today I've tested it again, but in difficult level, in this case my villagers aren't so fast, so I feudal with 31 villagers.

I've copied defrules from Training AI, of Bear The Great, about building extra mill to hunt but modifying it to make it possible in Dark Age. With my superfast advance in easiest I haven't enough wood to make them, but now I can see that perhaps is not a bad idea because now it works. Of course I need test if it causes me problems in wood to another important buildings.

Now the most interesting. My first flush strategy will be based in the famous article by Steve in AoKH (http://aok.heavengames.com/university/s ... map/flush/), and that’s because a I want an AI with a human behavior (as VNS_Halen or The Dragon) buy with a personal touch:
- I only create military units if it doesn’t result in idle TC. Villagers are the most important.
- Wood and farm technologies have next priority. Wheel barrow is important, but only if we have enough villagers (28?)
- I consider a waste pay for a military building and have it inactive, so my barrack will start spamming spearmen, although they will be trained only if haven’t free military buildings or if enemy has cavalry units.
- Later will arrive an arquery spamming skirms, with more priority than spearmen, they are better against enemy villagers.
- We continue with a blacksmith. Once built I’ll allow gold minig, because once I research fletching for my skirms, my archers will be more useful. Then civs with champions (except byzantines) will research man-at-arms because they’re better than spears except if enemy can attack with cavalry.
- Civs with blood lines, as Saracens, will make an stable for scouts. In next flushing strategies other civs will make a second barracks or arquery.
- Finally a market to equalize resources.
Future strategies will be trush (ideal for Spanish, Japanese or Koreans) mining stone in the transition to feudal; mat-at-arms-rush, gold mining in the transition to feudal, researching this tech before get fletching and archers and with two barracks and one arquery); or even with civs without champs train always spears to not waste resources in improve a dead line.

To decide when train counter units, I’ll use a few obsolete SN’s. Their value will be 0 if enemies can’t train that never, 1 if the unit to counter is not created but the building and age allow this, and 2 or more depending of their force (you need more light cavs to arrive to G-THREAT-CAVALRY 5 than knights, for obvious reasons).

When my Saracens flush well, then arrives their “krush” strategy. Starting with lots of monks (something like Arfii, Demon is another great monk rusher but I prefer only one monastery for this AI) and knights. But using as can arquery (for cav archers or foot archers depending of our civ and enemies), barracks for spears (only if enemy knights) and swords as can (if the tech tree contains champions, otherwise spears), specially vs mesos.
For civs without paladins I want use a timer to get knights only at early feudal, although I could make them until imperial transition or getting long swords tech. Even when cav timer isn’t triggered, you train light cav if monk’s threat is higher than swords or camel if it’s cav threat.
For unique units it’s more complicated. For Saracens it’s easy, you train mamelukes if cav threat > 1. But for Vikings I’m thinking about create berseks in castle age and forget them in imperial because barraks are cheaper than castles. For Teutons it’s worse, because I’m training TK’s but I don’t know if make also champs because they are faster. I think no, because to counter ranged units Teutons have better units.

I’ve upload my AI project, so if anyone decides test it and give me ideas I’ll be very glad. :D
2010, 18th December: The last versions I'm uploading are able to fight decently.
2010, 19th December: Now it's able to defeat stronger AI's, despite that lacks a few necessary rules
2010, 21th December: Its Counter System now works well.
2010, 23th December: Finally completed!
2010, 29th December: Stronger in general. With second barracks when enemy arrives to Castle Age.
2011, 7th January: Its flush starts with spears/skirms and turn later into swords/archers, if necessary.
Crusade 2.0 Mayans and Saracens
Crusade 2.1 Mayans (improved) and Saracens
Crusade 2.27 Britons added
Crusade 2.4 Huns and Persians added. Building system improved
Crusade 2.5 Random civ!
Crusade 3. Prepared for team games.
Crusade 4. Prepared for water maps.
Crusade 4.21. Forgotten Empires civs added. Warning this version doesn't use yet most FE units and techs, and mesos are bugged. Of course this only happends with FE version, for Conqueror versions (with or without UserPatch) mesos and everybody works awesome.
Crusade 4.3. Every setting. Every Forgotten Empires civs can use at least a unique unit and a unique upgrade. Warning this version doesn't use yet most FE units and techs, and mesos are bugged because they can't research heavy eagle upgrade. Of course this problem only happens in FE version, because that upgrade doesn't exist in Conqueror versions.
Crusade 4.41. Prepared for Forgotten Empires. Of course still works with 1.c and UP Conquerors.
Crusade 4.42. Perhaps my last update compatible with 1.c.
Crusade 4.42a. Its only change is the addition of sn-enable-patrol-attack set to 1 for a better battle behavior.
Crusade 4.42b. Now truly compatible with 1.c. Sorry for my mistake with 4.42 version. ;)
Attachments
Crusade 4.42b.zip
Perhaps last Crusade update
(136.01 KiB) Downloaded 361 times
Crusade 4.6 DEC21.7z
Betha uploaded 24DEC
(101.91 KiB) Downloaded 327 times
Crusade 4.41.7z
(85.64 KiB) Downloaded 226 times
Last edited by Campeador on Sat Jul 05, 2014 4:05 am, edited 76 times in total.

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

Re: Crusade AI Project

Post by Archon »

Campeador wrote:Well, surprisingly my AI can arrive to Feudal Age in 13:40 (14 villagers and loom researched with NO idle Town Center except the last seconds building first house)
You forgot to set to hard difficulty? :blink:

Standard difficulty takes much longer to train/build stuff.

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

Re: Crusade AI Project

Post by marathon »

Wheel barrow is important, but only if we have enough villagers (28?)
If you can't make your script take WB at, say, 32 vills exactly, then take it asap. Better a bit early than too late (45 vills).
I consider a waste pay for a military building and have it inactive
If you are defending or if you try to boom, it is necessary to have a couple inactive buildings. Have you experienced VNS_Halen's castle-age attack? You can't stop it with 2 barracks and 2 ranges. No way.
Later will arrive an arquery spamming skirms, with more priority than spearme
Most scripts that train trash prefer having more skirms than spears. Wood is cheaper and skirms are effective vs a larger variety of units. In fact, most strategies include units that receive bonus damage from skirms. They are good in feudal defense: they lure enemies. With thumb ring and a meatshield they are effective even against longswords.

m@a are strong in feudal. Their only weakness is archers, and they struggle against bloodlined scouts. But 5 spears can help against scouts. Scouts on the other hand really massacre archers/skirms. I train byz m@a. I can't stop IS_Machine's flush without them. Feudal spears are only useful against other spears or scouts. So, imo, m@a > scouts > skirms > archers > spears. Archers have the huge advandage that their castle upgrade is the cheapest. The first 2 are very food costly, so you shouldn't have too many of them.
I would suggest to have 3 unit-producing military buildings in feudal. No more cause you won't be able to feed them and advance to castle at the same time. Except when you want to flush very aggressively, suicidally agressively, like Goose does. 2 ranges 1 barracks 1 blacksmith, for example. In 3' you can have 8 m@a and a dozen ranged support. Do you really need more?
I believe that you can advance without market. Use it for now, but have it soft-coded because you may reach the point where you will have a balanced flush.

Saracens is an excellent selection. I made the mistake and chose Byz with their trash bonus and their cheap imperial. Now I train trash even against Goths...
Standard difficulty takes much longer to train/build stuff.
Does this mean that in hardest units are trained faster? I haven't touched difficulty setting for ages.

User avatar
ER
Waheguru
Posts: 2764
Joined: Sat Nov 08, 2003 9:23 am
Location: Johannesburg, South Africa

Re: Crusade AI Project

Post by ER »

The difficulty levels below hard cripple the ai in strange ways - training units takes longer and longer as the difficulty gets easier and easier, but it still gathers at the same rate as normal, so food looks like it is building up faster because it is using way less food on training villies over time. This enables it to reach a normal-looking feudal time, but with very few villies, so its econ is actually very weak. This was to tone it down against human players who wanted to play against a less powerful ai opponent. difficulty less than hard is quite meaningless in an ai vs ai situation. With hard, all the "crippling mechanisms" are removed in the game engine. I did test the actual crippling mechanisms way back, and what it meant in hards numbers, which I posted somewhere, but don't remember where that was any more :unsure:

User avatar
ER
Waheguru
Posts: 2764
Joined: Sat Nov 08, 2003 9:23 am
Location: Johannesburg, South Africa

Re: Crusade AI Project

Post by ER »

oh, and hard and hardest are essentially the same thing to the game engine, except the built-in resource cheats on harest. Technically, besides that, they are both uncrippled and function the same in terms of the mechanics of the game.

scripter64
Waheguru
Posts: 5891
Joined: Fri Jan 16, 2009 8:36 pm

Re: Crusade AI Project

Post by scripter64 »

Hi, Campeador! It's nice to meet you :)
Archon wrote:Standard difficulty takes much longer to train/build stuff.
Wow, good to know. Campeador, try to script for the Hard difficulty at first, to avoid this kind of unexpected behavior.
I hope to try your AI soon!

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

Re: Crusade AI Project

Post by Campeador »

Archon wrote:You forgot to set to hard difficulty? :blink:
Well, I really did it intentionally. As said, I want a non cheating AI to play vs humans and AI's in Hard, but I tested it in easiest to avoid enemy's AI attack me. Now I'm testing it in Hardest but with the other AI as ally. Of course I didn't know this behavior change, so this caused my surprise to my aparent superfast advance (although my time, 13:40 isn't really too great) when I see the best AI that only can collect 500 food when 26 villagers or so in the record AI's like Goose. It also explains why my now accidentally deleted Wonder Race AI was too bad despite its "quick" advancing. :unsure:
marathon wrote:
I consider a waste pay for a military building and have it inactive
If you are defending or if you try to boom, it is necessary to have a couple inactive buildings. Have you experienced VNS_Halen's castle-age attack? You can't stop it with 2 barracks and 2 ranges. No way.
That's why my AI will take 3 military buildings for every flushing strategy and construct another in the transition to castle. Of course it will need more as the game progresses, but with my test I'll can calculate how many.
marathon wrote:m@a are strong in feudal. Their only weakness is archers, and they struggle against bloodlined scouts. But 5 spears can help against scouts. Scouts on the other hand really massacre archers/skirms. I train byz m@a. I can't stop IS_Machine's flush without them. Feudal spears are only useful against other spears or scouts. So, imo, m@a > scouts > skirms > archers > spears. Archers have the huge advandage that their castle upgrade is the cheapest. The first 2 are very food costly, so you shouldn't have too many of them.
I only start with trash units because I prefer save 100 wood form the mine camp and I few villagers that I'll need to pump eco techs, villies and soldiers at early feudal. Once researching fletching, I'm sure that my archers will be a pain against swords that I train them if enemy skrims allow it, so mining gold it will be practical. Anyway, at this moment mining gold isn't so luxurious, and with a mine camp I haven't any problem with train swords, but only when its blacksmith tech are reasearched, because spearmen with them are so powerful as mat at arms without.
I'm agree with 5 spears vs scouts. In fact I pretend train them if enemy has a stable or if it is Castle Age and isn't meso, to prevent possible krushes. And any as I can if efectively it starts to pump scouts... or knights. :o
For future man at arms rush, ideal for infantry civs, I want start mining gold in the transition to feudal, precissely because swords are more all-around units. But in civs without champ I'm thinking about save resources for this upgrade, because anyway it's a dead line. Although I'm not now very sure, because playing as human I can see that m@a really afford it's cost in feudal. One exception are Byzantines, its spearmen are equally good as swords vs any melee attack, with the only drawbacks of 1 pierce armor less and bonuses from archers vs them. But it will be another strategy, trash rush.
For castle age archers, for Saracens I usually prefer cav archers, because of bloodlines, except if I have massed archers when arriving to castle or there are enemies with camels. In imperial I prefer hand cannoers to save heavy CA researching… except if massed CA. For Chinese it will be very similar, as them can get a great unique unit that is a foot archer itself, so this I’ll can use arquery range if others military buildings are busy and I want more soldiers (practically always) without being redundant with chuks.
scripter64 wrote:Hi, Campeador! It's nice to meet you :)
I hope to try your AI soon!
Thanks for the welcome. But I advice you to be patient to smash my AI. I’m quite busy and you know this is a slow process. Fortunately I’m not going to work until next Wednesday. :D

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

Re: Crusade AI Project

Post by marathon »

Good thinking, and tiring writing (you're not that good in English, keep working on them).

I agree with all, except one thing: spears are a lot weaker than m@a. Remember than m@a have a rof of 2.00, while spears have 3.07. Can you stop IS_Machine's gothic m@a rush with byz trash? I can't, but I am able to nail it down every time with as few as 8-10 m@a and 15-20 skirms, no more than 5 spears. With Japanese I train a dozen or more m@a and 15 skirms and no rush can pass through. Men at arms are the king of feudal warfare.
My script always destroys VNS_Halen's flush, that has many units. m@a are the key.

User avatar
Leif Ericson
Waheguru
Posts: 1318
Joined: Wed Dec 09, 2009 8:15 pm
Location: United States

Re: Crusade AI Project

Post by Leif Ericson »

Minor correction: spears have a ROF of 3.00. The 3.07 figure was calculated by running dozens of tests, but the genie code says spearmen have a perfect 3.00 rof. It's not like it is a big deal, though.
Currently exploring the vast oceans and intelligence of Age of Kings.

Happy Scripting!

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

Re: Crusade AI Project

Post by marathon »

Right. Spears' ROF == 3.00. My wrong.

Campeador,
you are doing well. Actually, you made me think, since I am debugging my script.
- You don't need that much effort for your first house. Simply have a rule:
(defrule
(housing-headroom < 2) ;you can set it to 3 or more later (merge rules)
(population-headroom > 4)
(can-build house)
=>
(build house))
and you are fine, including your first house. You can have 100% builders for the whole game: builders are tasked preferrably from the gatherers, but if there are not enough, they are tasked from explorers too. Same with cap builders.
For explorers you have to set gatherers below 100. If you have 80% gatherers and 50% explorers, you will never have more than 20% explorers, unless perhaps if you make all drop distances zero.

- For farms you'd better have a 90 food buffer but only when you need it:
(defrule
(or (wood-amount >= minimum-wood-for-farm) ; it's 70 for Teutons
(and (housing-headroom != 2)
(housing-headroom != 3)))
(.....)

I've never experienced any problems with this rule. If you spend all your wood on a farm and you have a housing headroom of 1, then you are definately building a house and, so, you are ok, while with a housing headroom of 4 you have the time to gather 30 wood. Remember: 25'' house building time + some seconds walking time < 50'' for 2 villagers (45'' for Persians).

- I see that you used the dark age gatherer percentages of BTG as I have modified them, that are good for a fast castle. I have slightly decreased woodchoppers in late dark age (9) for a faster age-up, but I am reviewing this thing: maybe the smartest idea would be to decrease them early and then slowly increase them towards the end of dark age: I think that the dark-feudal transition to wood is too violent. You may run some tests of your own or watch/modify my script if your feudal rules aren't ready.
In any case, you can slip off BTG's guideline and use the Excel and minimise the # of rules needed for your gatherer percentages. I suggest to always have the first 8 on food. Maybe add a 9th one for a while and remove him later.
I am going to try a 8-8-10-5 order, with a 9th food gatherer until vill 10. If it isn't enough for Saracens and Aztecs, then it's rejected.

- When you are advancing to feudal, better restrict farming, because you will need wood for buildings. I would suggest to have 12 farms max while advancing. Most of the time you will have 13-14 before pressing the button. So,
(defrule
(strategic-number G-AGE-STATUS >= GV-ADVANCING-TO-FEUDAL-AGE)
(idle-farm-count < 2)
(or (building-type-count farm < 12)
(idle-farm-count < 1)
(can-build farm)
=>
(build farm)
)

You could add more things, for example when you have all necessary buildings and enough wood for early feudal. Or, you can simply use a goal "farming-level", like in CPS Alexander. I am going to use it.

Post Reply