Building a better RTS AI. Counting future units as an obstacle

posted in DreamLand editor
Published September 16, 2024
Advertisement

In a previous entry I was saying that you should start from the end when building your RTS AI. First you (when I say you I mean your AI player) try to kill the enemy workers that's your goal number 1. If there are enemy marines near the workers that`s an obstacle to reaching goal number 1. You must take out the obstacle hence destroying enemy workers becomes goal number 2, goal number one becomes taking care of the marines. If the enemy marines are near enemy tanks, the tanks become an obstacle in the path to wiping the marines, yet again you must change your priorities goal number one becomes taking care of the tanks then follow the marines and last the workers.

When you win a battle usually you win by a narrow margin. That`s why when you build your battle plan you must count future enemy units as an obstacle too. If the enemy has three tanks when you decide to attack (lets say it's minute 7 of the game )and your units start moving from your base towards the enemy base by the time your units reach the enemy base he will have four tanks, after the initial exchange of fire between your units and the enemy units the enemy will have one more tank ready for battle counting 5 tanks in total. That why when you decide to attack before your units leave your base (at minute 7) you should be taking into consideration not 3 but 5 tanks on the enemy side.

If the enemy builds an early expansion and you don't do the same thing, it means that in the future the rate at which he gathers minerals will increase and surpas yours. You can count on more enemy combat units than you have in the distant future but less combat units than you have in the imediate future. Hence if you plan an early attack (which is the only good option in this scenario) attacking the expansion is a waste of time, if you do that the enemy will probably catch up and bolster the number of combat units and by the time you`re done with the expansion the numbers will be in his favor.

[edit]

I want to share a few more thoughts.

When a human player plays a game like Starcraft his thinking is driven by logic and hence possible to reproduce.

You can try to solve the problem of reproducing the behavior of a human player by attempting a brute force approach. You place the enemy units in every position on the map and move them to any position on the map and then figure out which moves are winning for him and you should be weary of. This is the exhaustive approach. In practice the action takes place in two or three hotspots on the map. The rest of the map is irrelevant. In the first stages of the game timing is critical, in the sense that you must have a determinate number of units at a certain time in the game. If you depart your attention from the hotspots i.e. you're wandering with your combat units around the map far away from your base and the enemy base, you will lose precious time. It's difficult to switch focus from one area of the map to another for a human. That's why it's not a good idea to build an expansion far away from your base. A computer AI doesn't have such problems of course but there is no reason for the enemy units to be somewhere else then in your base or his own base.

I`ll try to explain what a future unit is. What you see with your own eyes in one thing what you know that it's there but don't see is something else. You can follow the enemy with your mind even if you don't see him.

If you're playing against a human in Starcraft in the first minutes of the game the only thing the enemy can do is produce SCVs. That's a certainty. It's also certain the number of SCV's the enemy can produce in the first minutes of the game. You can know that without scouting. Then things branch in two directions, the enemy can go for an early expansion or continue with developing the main base. You can predict with accuracy how many combat units the enemy will have (and how many SCVs) at a certain time if he choses either of the two scenarios. It's a matter of math. You can do the prediction without scouting. But at this point as a player you must take a decision. You have a ‘ghost’ player evolving in two directions in your mind (but if you want to win it's about time for you know what exactly he is doing so that you can adapt your actions) after A the expansion is built (in ‘expansion’ tree branch) and producing more than it is consuming (on building the extra SCVs) or B four to six tanks are produced (in the ‘stick to main base’ tree branch) it slips. It becomes a matter of wild guessing and scouting/attacking becomes mandatory otherwise it's too many oranges to juggle with. The B scenario branches into two or three B1 enemy produces more tanks and marines and B2 enemy builds a Starport and air units B3 enemy builds an expansion. The A scenario also branches. You can't have a unique viable response/solution to all these possibilities.

1 likes 1 comments

Comments

MagnusWootton

That sounds about right thinking, if u want impossible to beat a.i. I'm sure u can make it, but does it make the game more fun.

Protecting the workers with soldiers seems like a fun way the computer can play, then you make the computer target the workers of the other side, and take out the soldiers in the way, then theres some balance of forces, you should only strike when u have the upper hand. That sounds like the basic way to do it.

September 17, 2024 08:58 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement