Turn based strategy AI

Started by
9 comments, last by IADaveMark 19 years, 6 months ago
I am making a turn based strategy game (like Civilization) and am wondering how to make AI for the game. Please Help. This game is like Advance Wars for the GBA. I have no experience making AI so I need all the help I can get. [Edited by - redtshirt on September 30, 2004 5:43:07 PM]
Advertisement
The only thing that I know about how the people that made Civilization made their AI, is that rather than making the AI smarter for higher difficulties, they made their AI cheat more for higher difficulties.

I'm guessing that some sort of influence map would be useful here.
I am the master of ideas.....If only I could write them down...
Quote:Original post by Nathaniel Hammen
The only thing that I know about how the people that made Civilization made their AI, is that rather than making the AI smarter for higher difficulties, they made their AI cheat more for higher difficulties.

Very true - Rise of Nations did exactly this - inhibit or increase AI resource collecting speed.

Turn based strategy games can be somewhat difficult to write AI for, if you're just getting started. You'll first want to implement a pathfinding system, so your units (whether human or computer-controlled) will be able to move throughout your map.

Then you can get started with the strategy part. I'd suggest a hierarchical AI system - the whole system is governed by a broad-plan AI that decides generally what needs to be done, then those commands are interpreted more specifically.
ie., General Plan > destroy cityMilitary > Choose units in attack state; choose general route, attackEconomic > Make more unitsUnit > for exact movements, how to move, whom to attack, etc.


Some good sources for AI are:
Generation5.org
AI Depot
and of course, Google.

But my favorite advice would be to figure it out yourself. It can be done, and you'll feel better that you did everything yourself. Granted you should read some of the basic theories behind everything first, just to give you a little head start.

Start small! ~Mushu
You are going to need to describe more about your game before anyone can give anything more than generalized help. I would think that in giving us more information about how the game is played/won, you will begin to isolate the information that needs to be analyzed and decisions that need to be made - at which point, you are unwittingly going to start to design your own AI without our help.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

A vague question gets a vague answer:

I would start with a highlevel AI objecy with some sort of state. Maybe for what phase of the game the AI is in either in time (relative to the game: start, middle, finish) or state (peaceful economic, aggressive, defensive, etc.) One idea is to have your state engine dispatch diffent functions based on a state and start with your first state (explore) and your first function for that state (see below).

Keep an array (or many) for all the squares on the board: maps. Have different arrays for different properties you may want to keep track of: unexplored, resources, threats etc. Have preprocessing phase where you fill up this map. (i)

Make a list (as in list) of all the pieces you control. Fill it (ii). Make a second list of points you would want to go to. (iii) Sort through all the pieces and assign them each a place to go based on one of your maps, sending the best piece to go to each assigned place. (iv) Have your UI handle the orders once the AI has decided where to go.

A good place to start is to see if you can get your AI to explore a board. If you can get your AI to take three or four pieces and send them off in different directions until the map is explored, you are halfway there. Really -- it is all variations on maps, state engines, and sorting lists.

If you ask more specific questions I can try and be more specific.
Quote:Original post by Mushu
Quote:Original post by Nathaniel Hammen
The only thing that I know about how the people that made Civilization made their AI, is that rather than making the AI smarter for higher difficulties, they made their AI cheat more for higher difficulties.

Very true - Rise of Nations did exactly this - inhibit or increase AI resource collecting speed.


This is so f***ing boring, please don't do this. I've played so many 4X TBS games now, I've got 'recognizing when the resource abuse kicks in' down to a fine art. This is not implementing an AI, this is upping a number so that the player has to waste more time doing tedious menial tasks. At some point the number gets upped too high and the player screams that the game is just grossly unfair.

I feel that way about the higher levels of difficulty for GalCiv, for instance. They spread so fast not because the game is smart, but because they're given this huge advantage in resources.
Cheers, Brandon J. Van Every(cruise (director (of SeaFunc) '(Seattle Functional Programmers)))
Don't do the resources cheat!

In the original Command and Conquer, you had to build silos to store your extra money. The extra money was stored evenly in all of your silos, and you could see them fill up with green the more money you had in them.

Well, I noticed on one of the last levels, as soon as the computer returned any resources to their refinery, all of their silos instantly went from empty to full. Funny, since one silo is more than enough for the money brought in by one resource-return. It was clear that instead of getting 700 credits from one harvest, they were getting at least 4000.
Not giving is not stealing.
Quote:Original post by InnocuousFox
You are going to need to describe more about your game before anyone can give anything more than generalized help.


An alternate design methodology, rather than asking anyone for help, or doing any programming, is to sit down with pencil and paper and reason about how you'd actually solve various problems presented in 4X TBS games. We usually do that sort of thing implicitly when we play 4X TBS games, and sometimes explicitly.

Like, let's say the whole map is black and you're starting out with a Scout. How do you typically search to find your next city site? How do you do it quickly so that your city production gets going the fastest? What assumptions do you make about possibly being on a continent or an island, and how to search in those cases? That sort of thing.

You could work an awful lot of these problems, and notice how you personally tend to solve them, before ever writing a line of code or considering what kind of AI architecture you're going to implement them with. If you understand what's the data and what you're processing, you'll have an easier time of it all.

I think you will also discover that the vast majority of game 'AI' is rather simple and pedestrian stuff. Just crafting a bunch of heuristics in an ad hoc manner, really.

Quad ruled graph paper is useful, as is hex paper. Here's a hex paper generator.
Cheers, Brandon J. Van Every(cruise (director (of SeaFunc) '(Seattle Functional Programmers)))
Good stuff, Brandon... that's what I was getting at in the rest of my post where I stated...
Quote:I would think that in giving us more information about how the game is played/won, you will begin to isolate the information that needs to be analyzed and decisions that need to be made - at which point, you are unwittingly going to start to design your own AI without our help.

The solution is to break it down to smaller solutions.

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Quote:Original post by vanevery0
Quote:Original post by Mushu
Quote:Original post by Nathaniel Hammen
The only thing that I know about how the people that made Civilization made their AI, is that rather than making the AI smarter for higher difficulties, they made their AI cheat more for higher difficulties.

Very true - Rise of Nations did exactly this - inhibit or increase AI resource collecting speed.


This is so f***ing boring, please don't do this. I've played so many 4X TBS games now, I've got 'recognizing when the resource abuse kicks in' down to a fine art. This is not implementing an AI, this is upping a number so that the player has to waste more time doing tedious menial tasks. At some point the number gets upped too high and the player screams that the game is just grossly unfair.

I feel that way about the higher levels of difficulty for GalCiv, for instance. They spread so fast not because the game is smart, but because they're given this huge advantage in resources.


When I was talking about the cheating, I was kind of pissed off that they take the easy way out. I was telling him not to be like the other guys. I don't know where to start, except for my advice to use some sort of influence map. The computer has to be able to tell if City A is far from the rest of the City A's owner's cities, for the AI to decide whether to attack City A.
I am the master of ideas.....If only I could write them down...

This topic is closed to new replies.

Advertisement