Gamasutra: The Art & Business of Making Gamesspacer
Designing AI Algorithms For Turn-Based Strategy Games

Printer-Friendly VersionPrinter-Friendly Version
View All     RSS
April 23, 2014
arrowPress Releases
April 23, 2014
PR Newswire
View All





If you enjoy reading this site, you might also want to check out these UBM TechWeb sites:


 
Designing AI Algorithms For Turn-Based Strategy Games

July 27, 2007 Article Start Page 1 of 3 Next
 

In action games the AI opponent always has the natural advantage: perfect accuracy and lightning fast reflexes, so the challenge in designing the AI for those games is making it act more human and to be beatable.

In turn-based strategy games the tables are turned. Speed and accuracy are no longer important factors and the cunning and intuition of the human player will easily out match any AI opponent. In fact, it's nearly impossible to design a AI that can beat an experienced player, but that is not really the point anyway.

The challenge is to make the AI's attack and defense strategy to appear intelligent and thought out, providing a challenge but letting the player win in the end. Once the player has familiarized himself/herself with the tactics of the AI the game rapidly gets boring, so a certain amount of unpredictability is desirable.

Challenges Involved: Looking At A Typical Strategy Game

The AI design problem is easiest understood by taking a real life example, in this case we take a space based war game.

Our example is what's called a 4X game, where you must expand and dominate the galaxy. Each player has war ships and colony ships and starts with a home planet and can colonize habitable planets.

A first attempt at writing the AI would be a simple algorithm to assign orders to each resource (i.e. a planet, or ship), starting with the most important first. Defending planets with production queues has the highest priority, because they are the most valuable.

The next highest, is defending colonies without production queues, then attacking enemy home planets, then colonizing habitable planets, then attacking enemy ships, then repairing damaged ships and lastly exploring uncharted territory. So, we take the highest priority task first, and check for any enemy ships that are close to our colonies.

As you can see in the image above enemy frigates X & Y threaten both the AI's home world and colony. So, we find the closest warships and assign them to attack. You might see here the flaw here in our algorithm. If by chance, frigate Y is handled first, destroyer A will be assigned because it's the closest. Then, when Frigate X is processed, the only ship left to attack is destroyer B, which is too far away to reach it and Frigate X succeeds in bombing our home planet. It's obvious that Destroyer B should be assigned to Frigate Y and Destroyer A to Frigate X.

Also, other problems can occur with this simple algorithm. Have a look at a more complex scenario:

In this new scenario we have Destroyer A badly damaged from a previous attack. It would be a futile sacrifice sending it into battle again. It's wiser to send it back to the home planet for repair. So, that leaves Destroyers C and B to defend our colonies. But destroyer C is too far away to reach frigate Y in time and would be better served to bomb the enemy colony, seeing as it's so close (not to mention, that fuel conversation is important too). Meanwhile, the AI colonizer is armed, and could be diverted from its primary colonization mission.


Article Start Page 1 of 3 Next

Related Jobs

Linden Lab
Linden Lab — San Francisco, California, United States
[04.23.14]

Lead Engineer
2K
2K — Novato, California, United States
[04.23.14]

Lead Mission Designer
Gameloft
Gameloft — New Orleans, Louisiana, United States
[04.23.14]

R&D Game Designer
SOAR Inc.
SOAR Inc. — Mountain View, California, United States
[04.23.14]

Game Designer/Narrative Writer






Comments


James O'Neill
profile image
hi, i am currently working on a turnbased stratagy on mobile device. it has all the functionality that i would like apart from the ai aspects for a single player. this is the first ai document i have read that actualy made some sense to me. i would just like to ask a few questions. could you please elaborate on the modifyers for me? can these be completly random or are you calculating them based on the objectives of the game? should they be high or low numbers or does it even matter?



or is it possible to point me in the direction of some reading material that will expand on what you have talked about here.



as you can tell this is the first peice of ai programming i have ever had to do. i have never had a lesson in the subject because my course took me in a diffrent direction. saying this i still have part of my final project in the area so some help would be much appriciated.


none
 
Comment: