Ticket #707 (closed enhancement: fixed)
Implement Opponent AI
|Reported by:||k776||Owned by:||Philip|
|Priority:||Must Have||Milestone:||Alpha 9|
|Component:||Core engine||Keywords:||ai, opponent, player|
We need an opponent AI.
Try to make it as flexible as possible. Perhaps in JS, so that other AI can be written. Globulation 2 had some good AI's (Numbi was easy, Nicowar was tough, and Warrush was a real test of speed). Each AI in this game should inherit from a base AI, then maybe allow tweaking of values? For example, warrior_to_worker_ratio or warrior_build_rate or min_attack_group_size. I'll leave the details up to you.
Basic Implementation: (women, housing and harvesting)
- Builds women from town center
- Builds houses when needed (should always try to keep ahead of the units being built, so it never hits the cap)
- Assigns women to gather the resource needed the most. This is determined by what building is next in the chain of buildings. The idea is that if something is built (unit or building), women are assigned to replenish the resources spent building it.
- Replenishes workers if they are killed. The idea being, if I kill 100% of it's workers, and it has resources to build another, it should see that, and act accordingly.
Medium Implementation: (warriors, defense, and groups)
- Builds warriors in a ratio of 2 women, 1 warrior (for the easiest AI, see notes above about changing the warrior_to_worker_ratio)
- Builds defensive structures at certain places around the town center (one per house seems adequate, maybe a house_to_tower ratio value that can be adjusted, to turn an agressor into a defender).
- Units form groups determined by min_attack_group_size and max_attack_group_size (random number in between).
- One group (see above point) moves to defend a building when it is being attacked. When that group loses 50% of it's force, another idle group is called in. In this way, if the player attacks one building, and then attacks another on the other side of town, the force won't be on one side or the other, but be split (the first group goes attacks the initial attack, and the second group goes and attack the other attack).
Complex Implementation: (attack, slaughter)
- When idle groups of warriors (see above) are awaiting orders, and more than 2 groups exist, the third group is sent to attack. So to reiterate, two groups will always be at the town/city protecting it. How big those groups are are determined by min_attack_group_size and max_attack_group_size.
- The attacking group attacks the enemy structure closest to their town center, and ignores other AI players structures, so it only attacks human player buildings.
- When 2 groups are defending the town, and a third is attacking buildings, a fourth is sent to slaughter the enemies workers. Namely around remove mills and farmsteads.