Building a better RTS game AI, this is part 3 or 4 by now
-
Previously I was saying you could setup your attack by sending a group of units G1 to the enemy camp and when they get caught in a fire they can’t respond to they should retreat to a safe distance. Then a new group of units G2 of different type should be sent to remove the enemy units posing a problem to G1. The disadvantage of this tactic is that the remedy units might not be available when the situation described above takes place. That means postponing the attack. The solution I think is to think ahead. First you need to scout the area where the attack will take place. You start from your base all the way to the enemy camp along the path on which G1 will move. The enemy might have units deployed along the way. For example if your units are fragile against tanks you need a strip of land of 10 tiles (or whatever the attack radius of a tank is) to the right of the path and a strip of 10 tiles to the left of the path free of enemy tanks. If this condition is met you will know your units will be safe while they are traveling. If enemy tanks do exist along the path you can bring in tank counter measure units. Bringing TCM will follow the same rule: make sure the path is safe first if not bring in obstacle counter measure or see if there is another path to get safely to the target unit ( I think I should have started with the last one) The advantage of the second approach is that the attack takes place all at once. G1 leaves your camp only when G2 is ready to clear the way.