AI are really hard to make, they must:
- Don't be too heavy ("Pioneerz" AI can make the XBOX360 lag sometimes...)
- Don't be silly (a good game with a stupid AI is a waste)
- Don't be too smart (if the AI know the perfect solution, you will always die)
- Don't cheat too much (it's supposed to follow the same rules as you)
AI became complex really quickly, it's really a pain to debug.
And in strategy game, AI is incredibly big.
So what have been done in Little Kingdom?
I haven't aimed for a perfect AI; I've aimed for a realistic one.
It doesn't analyze all the possibilities and don't choose the best solution.
It's a fairly simple AI based on randomness and script. (Pioneerz 2 AI is more complex)
The buildings AI: A random position is selected, and then I launch the "selection script".
It there is something interesting to build here, do it. (In most of the case, nothing is build)
As the AI is launched a lot of time, the building pace is ok.
(it's not too heavy because the script AI don't consume a lot)
In addition, we can't guess what the AI will do.
The trade AI: It takes a look at the resources.
If you have too many of a resources, a trade begun, if not the trade is stopped.
And so the Normal AI has a nearly human behavior.
The easy AI doesn’t trade, don't delete buildings or resource. (=> they miss gathering possibilities and improve at a slower pace)
The hard AI cheats a little when gathering resource. (Nearly impossible to see it but it help the AI to grow quickly)