View Single Post
  #15  
Old April 17th, 2004, 10:23 PM

LDiCesare LDiCesare is offline
Captain
 
Join Date: Apr 2004
Location: France
Posts: 820
Thanks: 4
Thanked 33 Times in 24 Posts
LDiCesare is on a distinguished road
Default Re: SUGGESTION: AI troop building algorithm

Hi!
I don't get this one:
- priest w/o magic IF turnnumber*3 < numberofpriests
If you have no priests, this condition will always be false and you'll never build any. Isn't that supposed to be a >?
In general, I'm afraid these rules will let you build too many units that resist fights well and not enough fodder if you need fodder. It also won't adapt to the opponents. I don't like rules which don't adapt themselves to the context.

In my own game, I programmed the ai to adapt itself to the opponent. This means it tries to have a certain distribution of forces, based not on types of units -not moddable- but on unit abilities. So I basically say I want a distribution of f.e. 20% archers, 20% fast units, 40% heavy infantry, 10% leaders, 5% fortresses, 3% labs, 2% temples, and the ai looks at the current distribution of units it's got and builds new units in order to be able to reach that goal. This means you have a 'fitness' function evaluated for each unit you coudl build: If you need more priests, the system will pick a priest. If you need more mages, it will build a mage. If you need both, it will build a priest that also has magic powers.
I included fortresses, labs, etc. in the distribution because I see it as distribution of the money to be spent (and yes the figures are silly - you probably need more temples than labs). That way if you have a lot of troops and only one fortress, the fitness of building a fort somewhere will be huge, while building any kind of troop will be low. This one may be tricky since you can always do something with more troops but not with more fortresses, so you may want to exclude fortresses from the list. However, the original proposal of building fortresses once every ten turns if some conditions effectively means fortresses have a weight of 10% of all money spent.
I'd also suggest budgeting in advance: You plan to build this or that next turn, with a set priority. This lets you build up money for buildings when necessary.

Note it's possible or even desirable to use the enemies' distribution of forces as your own target if you can't think of a distribution yourself. In particular if you are swarmed with crappy light infantry, you may want o build more crappy troops yourself so your heavy infantry won't exhaust itself to death against huge hordes. Or decide that known enemies of type 'light infantry' means you must build more of the type 'archer', and 'undead' requires more 'priests'.

I coded something like that in my own game. You can check a more thorough explanation of the algorithm this: link if you are interested.
Reply With Quote