Ticket #707 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

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.

Change History

comment:1 Changed 3 years ago by dustin_

Place to load opponent AI

  • Create an empty file referenced by the player manager, and game set-up files, that can be slowly changed into opponent AI so that people can build and test snippets of script.

comment:2 Changed 3 years ago by feneur

Hmm, in general it seems like a fine approximation of what the AI will have to do to begin with. One thing I think we need to have it do to some extent already from the beginning: utilize the fact that citizen soldiers are both soldiers and gatherers/workers, something I cannot see in the description above, though it may just be caused by the list above not being exhaustive.

comment:3 Changed 3 years ago by k776

  • Milestone changed from Alpha 4 to Alpha 5

A basic AI system has been implemented. And it will be expanded upon in the next release.

comment:4 Changed 3 years ago by k776

  • Milestone changed from Alpha 5 to Alpha 6

comment:5 Changed 3 years ago by k776

  • Milestone changed from Alpha 6 to Backlog

An AI has been implemented, and slowly developed.

I think I'll backlog this though, instead of mark it as resolved, since we still need a really quick AI that is good at planning and can actually beat a player.

comment:6 Changed 2 years ago by Spahbod

Shall we mark it as resolved now? qBot is not a bad AI.

comment:7 Changed 2 years ago by k776

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from Backlog to Alpha 9

Agreed. It still has a while to go (ally recognition and support, ship/sail based commands, etc), but it's an on going process, which won't need a ticket. Alpha 9 made qBot quicker too, so I'll mark this ticket closed off for that milestone.

Note: See TracTickets for help on using tickets.