-
Notifications
You must be signed in to change notification settings - Fork 0
AI decision making
For building units, the AI follows a simple routine. In that routine a function that returns the next unit that should be build is called after every unit that was build. The AI then waits for the right amount of gold to build that new unit and calls the function again to get the next unit it should save its money towards.
For this calculation the AI simply looks at the distance that the nearest enemy unit has to the own base.
- If this distance is really small (under 20) only close combat units will be build to fend of the attackers. Archers would die to quickly. So only lancers/soldiers are build. Lancers for tankiness, while the soldiers kill the attackers.
- If there are only enemies outside of the 20 radius, the AI will build soldiers and archers for a fast attack.
- And if there are no enemy units to be seen, only archers will be needed to box the enemy inside its own base.
All of those build decisions are a bit randomized with a possibility of 1/3 that the AI will build whatever unit instead of the units it would normally build in a situation. This is done so the AI isn't completly predictable.
- Clear a circle with a radius of 30 around the own base from all enemy units.
- Conquer the near resource points (behind the own base and in the middle, in that order). But before just walking towards that point, kill the enemy units on it first.
- Clear the danger zone (everything in front of the enemies base) from all enemy units.
- Conquer the resource points behind the enemy base. But before just walking towards that point, kill the enemy units on it first.
- Attack the enemy base.
At the beginning of the game it is most useful to send the first three units to the three resource points near the own base (two in the corners, one in the middle). After that the units should probably advance against the enemy, since a fight for the middle resource point is likely. After this the normal routine should take over.