AI for turn-based strategy game in style of Total war

Started by
8 comments, last by aganm 6 years, 6 months ago

Making a turn-based strategy wargame set in the near future. Each nation controls cities on a world map and moves armies around the map similar to Total war.
The fights are also turnbased but AI for these are under control (somewhat).

How would I go about making AI for the computer players? (the player controls one empire while other empires controlled by AI make up the opponents in the world)
Stuff to handle for the AI:

  • What buildings to construct in cities (gives resource bonuses, unit production capability, defense, lower unhappiness etc)
  • Some other city management like setting taxrate and other policies
  • What military units to train and to what extent (various land, sea and air units are available)
  • How to move armies around (defend or attack cities, move ships to position for launching missiles etc)
  • What to research (unlocks stuff and gives bonuses)
  • Some simple 

This looks like A LOT to handle. Some things can be fairly random without making the AI look too stupid (some research choices for example). Army movement is important to get right. Even AAA-games like total war and civilization doesnt handle all this too well so some oddities can be accepted :) but how would I go about getting it somewhat right?

Thanks 
Erik

Advertisement

Congrats on tackling one of the hardest genres for AI in games. You could spend an entire lecture series on how to do all of the above. Not terribly conducive to a message board reply. Additionally, if you don't know AI at all, this is going to be a TON of work. I'm talking years.

Start your research on AI tech here. (And this doesn't even cover things like pathfindinging at all.)

http://intrinsicalgorithm.com/IAonAI/2012/11/ai-architectures-a-culinary-guide-gdmag-article/

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!"

Incidentally, the Civilization games (which are the staple of turn-based strategy) all have the source code available. (e.g. for Civ 5, you download the SDK) Dig into that and find out how they did all of the above.

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!"

Well o dont have years for the ai alone:)

But non-AAA wargames exists so there must be acceptable shortcuts. i can accept simplified rules or even cheating for ai agents (i know that's how difficulty works in civ for example)

How about an overarching finate state machine (grow, attack, defend) . On top of that each city will decide it's action each turn like: produce defence if currently less than 20p of defensive troops per city level. Otherwise choose from a set of options with weight calculated from some conditions. 

A possible route? Any examples or tutorials of that kind of simplified behaviour?

I would start by enumerating the possible actions. Then write a heuristic function that assigns utility values (i.e. how happy the agent will be with the result) to the actions. Pick the action that maximizes the utility. If you want some variety, use SoftMax instead of picking the maximum, or add some randomness to your utility evaluation.

Assigning reasonable utility values to actions in a game with very complicated state can be challenging, but you can start fairly simple, decide what units the utility will have (this is fairly arbitrary) and tweak the heuristics whenever you observe behavior your don't like. There is a certain art to getting this to work well.

One piece of advice: If your utility function ends up being the sum of a bunch of terms (which is reasonable), make sure you build debugging tools to see what the value of each term was for each of the available actions. That will make your life much easier down the road.

 

I'd recommend watching the video "Playing to Lose", which might get you think about the problem in a slightly different way:

 

Yeah ive seen that video it's good info.

If you're going to do it, Alvaro nailed it. Each decision should be a scored utility function for it's worth/desirability. Pick the best one and go. Note that different entities will be doing their own "thinking". e.g. where a unit moves is a different thought process than what should I build next.

There is a brief portion of this combo lecture that talks about the AI in XCom: EU. They used utility values for scoring the moves in their tactical turn-based game. (Start at 16:30)

https://www.gdcvault.com/play/1018058/AI-Postmortems-Assassin-s-Creed

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!"

The best way to have a good AI is the make the game simple for the AI. Take Paradox grand strategy games for example. There isn't much tactical positioning to do by the AI. The tactic is to move an army to an enemy army. At this point, the combat is simulated for both the AI and the player based on the armies stats.

This topic is closed to new replies.

Advertisement