suliman

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

Recommended Posts

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

Share this post


Link to post
Share on other sites

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/

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now