AI: Decision trees

Watching the AI play with itself..

On the hierachy of lameness, you have:

  1. A guy playing a video game
  2. A guy watching his friend playing a video game
  3. A guy watching computer players play each other in a video game.

I am at the bottom.

I watch computer players play each other. To see what smart things they do in different situations and what dumb things they do.  So much of good computer AI really boils down to play testing. The best algorithms in the world are no match for real world playing. And what looks like a good idea on paper can end up being a disaster in the real game.

The decision tree in Galactic Civilizations is actually pretty significant. Consider the choices it has to make. Then consider other strategy games you've played and think of the choices that have to be made there:

  1. What should my tax rate be? The higher, the more unhappy my people will be which will slow down population growth but the more money I get.
  2. What should my spending rate be? Spend too much and I'll run out of money or not have enough to make quick purchases. Spend too little and I'll fall behind.
  3. How should I set my ratios of research, social, and military?
  4. How should I design my ship? There's an infinite number of designs possible.
  5. What technology should I research? There's over a dozen distinct, non-connected branches in GalCiv (look carefully at the # of branches in other games -- usually less than 3 or 4). Pick the wrong one and my economy might be weakened or maybe my industry weak or my military weak or my morale weak or maybe I won't be able to get those special worlds or maybe my logistics will be too low or maybe my miniaturization won't be competitive and so on.
  6. What should I put on my planets? Do I use that special farming tile (i.e. put a farm on it?) or should I sacrifice it for another factory or a research center or save it for a galactic achievement or a fusion power plant? Or maybe build a farm but if I do, will I have space to put on morale improving buildings?
  7. How should I use my military forces? Is the human player my friend or is his build up designed for a sneak attack? Should I escort my transport even though my transport moves at 10 moves per turn while my escorts only move at 4 or do I send it at that undefended planet that is only 12 moves away and the fog of war might be hiding an enemy there?
  8. Should I hold back my fleet and wait for more shpis to be built to make a bigger fleet or should I send it out now and wreak some havoc?
  9. Should I build a transport (only transports can take planets -- unlike in many other games where any unit can conquer the city/planet/star/) or a constructor to take that nearby resource?
  10. Should I build a starbase near my planet or should I extend my range with a starbase?
  11. Should I upgrade my starbase or construct a new one by a different planet?
  12. Should I put resources into spies and if so, how much?
  13. What should I be doing with my spies? Protect my worlds or send them out? If so, which worlds should they go to?
  14. If I'm sending a spy to a given world, which planet improvements should I take out that will do the most harm to them based on the strategy that I perceive they're taking? Or alternatively, which enemy agent should I nulify?

Some of these decisions are more complex than others. The one I have the most difficulty with is one of the more straight forward -- what to research and when.  I've had others I've had to struggle with -- I didn't write, for instance, the planet improvement placement code in GalCiv II, but in Dark Avatar I've rewritten it (for better or worse) to something that matches more closely the way I play the game.

In most strategy games that have computer opponents, the decision tree is kept very small.  Think through the games you've played and consider the # of actual decisions that the computer opponents have to make. And by decisions, I mean actual choices as opposed to choices that are pretty obvious.

Consider your first 20 turns of Galactic Civilizations II. What should you research? If you research the same thing (i.e. you script it) you become predictable. If you just have the computer players randomly select what it should research, it becomes pretty obvious and ineffective. 

Having computer players that don't cheat makes it tough too. I can't just tell the computer players to send a colony ship to the closest uncolonized planet. It has to know about it or at least make a reasonable guess based not on real data but based on what the map looks like.  Very often players will complain that the AI should have not done this or that without realizing that the AI made its decision because it couldn't see their ships or a planet. Sometimes players will insist that the AI must know where the good planets are because it did what most good players would do -- built a colony ship and sent it into a sector full of planets that were on the galactic sensor map (the odds were in its favor after all).

In most games with tech trees, players are pretty much expected to research every technology. In GalCiv, players are punished for doing that. The tech tree is too big. Players have to pick and choose which techs for their strategy for a particular game. That means the AI can't just randomly muddle through. It has to wisely pick.  At lower difficulty levels, that's what I have the AI do -- randomly pick technologies. But higher up, people expect their opponents to be thinking about this stuff carefully -- and they do.

And so on a variety of maps, a variety of players, I watch them play each other. What's worse, I like doing it. ;)

49,369 views 21 replies
Reply #1 Top
I am at the bottom.


I can read no further without saying 1) GCII is not a mere "video [deck] game" and 2) The game spectator role (video [deck], PC, or otherwise) is perfectly respectable given the fact that individual skills and tastes vary.
Reply #2 Top
And what looks like a good idea on paper can end up being a disaster in the real game.


Bollocks to the "on paper" part here. What looks like a good idea can *always* end up being a disaster, whether or not you had time to read, think, and write about it.

The one I have the most difficulty with is one of the more straight forward -- what to research and when.


This makes me think I might be a decent student of GCII. The question list is really interesting to read, but b/c I'm a tech-obsessed player, this gives me hope that I might eventually earn an A if the Metaverse stays around and I manage to post enough games.
Reply #3 Top

Here's a game that just got completed where the Terran Alliance ultimately defeated the Drengin, Torians, and Altarians. The Drengin were the AI I was working on today to improve. I spent last night mostly on the Terrans and the effect was pretty good.

Drengin ship design

What techs the Drengin had researched:

 

Terran Alliance ship design:

The ship that allowed the Terrans to win:

What techs the Terrans had researched:

 

The Terran Home World:


Summary:
0 morale improvements (bad)
2 economy improvements (great)
2 factories on bonus spots (good)
2 research labs (good)
1 farm on farm bonus (good)
2 galactic achievements (great)

A pretty optimal use of the planet other than not having a morale improvement bonus.

Let's see how the Drengin did:


Summary:
1 morale improvement (upgraded) (not bad)
1 economy improvement but never upgraded (terrible)
2 enhanced factories (bad for this late in the game)
2 research labs (good)
1 unused tile!!! (awful)
1 tile that just needed habitat improvement (awful)

It's pretty easy to see how the Drengin blew it. For shame. The Drengin had better weapons and defenses on their ships but were incapable of creating a fleet to support it.

Back to mines...

Reply #4 Top
Well, I've already did #3 a few times... And worst of all, sometime it wasn't even AIs that I coded myself or anything like that.


1. What should I be doing with my spies? Protect my worlds or send them out? If so, which worlds should they go to?
2. If I'm sending a spy to a given world, which planet improvements should I take out that will do the most harm to them based on the strategy that I perceive they're taking? Or alternatively, which enemy agent should I nulify?


Are the AIs able to remove their spies to use them elsewhere? To think : "I need to nullify this enemy spy or I need to stop the growth of this civ, so I'll remove my spy on the planet of an almost dead civ..."

I've never seen it does that though.
Reply #5 Top
AI's who are allied should gang up spywise on a powerful player. Not as a cheat, but as a legitimate cooperative tactic. Players should be able to ask an allied AI to spy on another race as well.

As for the techs, the AI should be very aggressive on tech trading, and even offer a new tech to a player if relations/distance make it feasible- if the player offers enough. If most players will sell the farm for a tech and make it back trading to others, why not have the AI do that?

As for planets- AIs should never waste a research or manufacturing tile, even if it goes against the overall idea of the planet- ESPECIALLY in the case of research tiles.
Influence tiles I can see wasting- and usually do, unless the planet is high PQ near another planet, or they are being culturally attacked. Farming tiles I tend to use- for the influence/tax bonus they provide. Population means more money- and 100% morale with max pop means 0 growth, so I use farms more then most people, and will take a morale hit to do it.

AIs at peace and not prepping for war should rushbuy projects when possible
Reply #6 Top
Personally I don't build galactic achievments on my homeworld. The civilization capital's increased population is like a free farm on that planet.

Galactic achievements always seems like a bad idea to put on a capital planet, I always threw them on smaller planets with low populations I was not going to get much out of anyway. An econ building on a capital is worth much more than an econ building on a base population planet.
Reply #7 Top
Diplo Trans I will rushbuild no matter what- that tech is worth 10k-20k credits over a game...


Reply #8 Top
The political capital is great for your home planet. I usually build two morale improvements and a farm, then replace one of the morale improvements with the political cap - a good influence bonus for a high population planet, and the slight increase in morale bonus is good, too.

One thing I still ocasionally see in the DA beta is an AI faction building one of its capitals (usually the econ capital) on a planet deep within my sphere of influence. In such a case, I am almost certain to culture flip it eventually. Even if I don't, the AI is bulding a valuable and unique improvement on a world far from home that it can't adequately protect in a war.

In every other way, however, the AI improvement building has gotten a lot better in DA. The difference is refreshing.
Reply #9 Top

Personally I don't build galactic achievments on my homeworld. The civilization capital's increased population is like a free farm on that planet.

Galactic achievements always seems like a bad idea to put on a capital planet, I always threw them on smaller planets with low populations I was not going to get much out of anyway. An econ building on a capital is worth much more than an econ building on a base population planet.

Depends on how many colonies they have, what the quality of those planets are, what the likelyhood of obtaining more colonies and what number of other colonies they might obtain at a distant point depending on strategy. (seriously, these are things it has to take into account -- a lot of players only play on a single map size, the AI has to be ready to handle not just different map sizes but custom scenarios as well).

Reply #10 Top
What techs the Drengin had researched:

Hmm, how do you zoom out that far on the research screen? Is that new with Dark Avatar?

On the hierachy of lameness, you have:

1. A guy playing a video game
2. A guy watching his friend playing a video game
3. A guy watching computer players play each other in a video game.

Reply #11 Top
Is that new with Dark Avatar?


Yes it is, and it's a great feature.
I am at the bottom.


Sturgeon spend most of their lives on the bottom, and they produce caviar.
Reply #12 Top
All I know is this: If the AI in Dark Avatar finally starts researching Good and Evil and improved government forms, Im screwed. Ive built my entire playstyle around the fact that the GC2 AI doesnt research these, or doesnt do it ill its far too late to matter(at least on every difficulty up to and including "Crippling").
Reply #13 Top
This was the first time I'd seen the streamlined tech tree and I'm a big fan. Is there a slightly higher-res version that's a bit more clear? It's tough to read the names of some of that stuff.

It seems like the AI vs. AI tests require quite a bit of analysis to see their effectiveness. It would be interesting to see a rating system (perhaps for players, too) similar to what you get at the very end of a game that might provide a better indicator for effectiveness (or the why portion of it). I don't have a good example off-hand, but maybe a resource usage guide (ie 50% of all planet tiles were used overall, average of 2 ships per planet, "theme" pursued by AI/player- cultural/tech/miliatary, etc.).
Reply #14 Top
Is there a slightly higher-res version that's a bit more clear? It's tough to read the names of some of that stuff.


You can zoom in and out using your mouse wheel. Zoom in to read, and out to get to a far branch quickly.
Reply #15 Top
Just a general question, what about a general adaptive AI, is it something that's just beyond what we're able to implement in modern games?
Something that reviews the player's game and add's it to a comprehensive decision tree developed based around all the player's previous games created to counter that player's specific strategy.

Here's why I ask...
A friend of mine (extremely analytical guy) pretty much grew bored with the game once he developed a single winning strategy and proceeded to hone it to razor like sharpness and the AI could not match it. Once he's got a strategy perfected the game looses its appeal.

Personally, I like to play with different strategies each time and repeating the same game strategy over and over would drive me nuts.. but my friend thrives on that type of mastery of a build order. And frankly I'm looking forward to the day he gets his backside handed to him by an AI that recognizes his strategy and knows how to defend.
Reply #16 Top
I was just thinking that in order to truly appreciate which technology or improvement is best for its situation, the AI needs to consider opportunity costs.

For example if I start upgrading buildings at a planet which is a plentiful producer of ships, there will be a reduction in military output because unused social production is added to military. One of the main reasons that I disable automatic upgrades at planets like these is because the opportunity cost of completing the upgrade (slower ship production) is usually not worth it. Then there's the increase in colony maintenance from newer buildings - yes they are more effective, but older buildings are in some cases sufficient enough, especially on those low-population outposts.

Similarly with the cost of research rising as each new technology is researched, there is an opportunity cost for each project. To strategise, you must decide what you need now, what you'll need to survive, and what you'll require to win.
Reply #17 Top
I was just thinking that in order to truly appreciate which technology or improvement is best for its situation, the AI needs to consider opportunity costs.


I'd like to see the AIs able to take an approach that reflects the "role playing" differentiations among themselves. It seems like an AI led by the War Party should have a different formula for "opportunity cost" than an AI led by the Technologists or the Mercantilists. The long-term goals for those parties are different, so their short-term choices for improvements might (should?) also be different.
Reply #18 Top
What technology should I research? There's over a dozen distinct, non-connected branches in GalCiv (look carefully at the # of branches in other games -- usually less than 3 or 4). Pick the wrong one and my economy might be weakened or maybe my industry weak or my military weak or my morale weak or maybe I won't be able to get those special worlds or maybe my logistics will be too low or maybe my miniaturization won't be competitive and so on.


Uh oh. Less than 3 or 4 vs over a dozen? Not true if you ask me. Just because ship components or structure upgrades or whatever are spread over several sub-branches, it doesn't necessarily make it any "richer" than any other game (what games are those BTW?). Most of it is essentially imposed by how the game works, so the problems that arise for the AI (and we know it does have plenty of those) are actually by "developer choice" if you will. So, you chose the mechanics, you deal with the problems    Seriously, it's only logical that implementing complex systems can only make it harder to have a decent AI.
Reply #19 Top
Not knowing about the new feature, I just assumed that Frogboy had a monitor that's actually big enough to show the whole tech tree at once. I was like, "Wow, it's good to be rich."

Here's a game that just got completed where the Terran Alliance ultimately defeated the Drengin, Torians, and Altarians.


This is something I've always loved about GalCiv, the fact that the computer players are capable of actually beating each other and affecting the game history instead of just waiting for you to beat them up like they do in Civilization.
Reply #20 Top
Then there's the increase in colony maintenance from newer buildings - yes they are more effective, but older buildings are in some cases sufficient enough, especially on those low-population outposts.


Why are new buildings on low-population outpost not worth it? I thought that people only deliver money via taxes and that production is just matter of building stuff and of course directing money to it via expenditure sliders. So my question is: how are production and population of a planet linked? Are they linked at all?

Thanks for your (potential) replies!

(Hope this is not a newbie question)
Reply #21 Top
AI: Decision treesWatching the AI play with itself..
By Draginol on Opinionated Techie
Posted January 17, 2007 18:42:29


Some of these decisions are more complex than others. The one I have the most difficulty with is one of the more straight forward -- what to research and when.

I know this is simplistic, but you must have already established a set pattern of behaviors for example - rush phase during initial planet colonization, followed by a consolidation phase where the focus is improvements, economy, and populaton growth followed by an expansion phase where a military is developed to obtain new colonies and counter threats. Your AI research is probably tailored to whatever phase the AI is in - since they would tend to be need driven. However, getting the AI to efficiently evaluate what it needs is the crux - establishing goals is always a direct reflection of how accurately the programer represents and quantifies value for the AI. I wish you continued success in this endeavor....