Frogboy Frogboy

The problem with AI in games

The problem with AI in games

I’m going to try to keep this as brief as I can.

One of the most common complaints I see about strategy games is that the AI doesn’t play well.  That is, in fact, a reality and there are a lot of reasons for it which I want to talk about in this blog.

The biggest factory today against good AI is the bell curve.  If you can make the AI “good enough” to beat 90% of the players on a reasonably high difficulty, it gets very tough to justify the extra expense in making it better.

As much as people complain about AI in say, Civilization V, it is probably good enough to beat most people on Prince or higher.  But that is little consolidation to those who find it easy to beat.  The same is true on Fallen Enchantress and its expansion, Legendary Heroes.  Once you make it good enough to beat “most people” it gets hard to justify spending money on more time on it.

A friend of mine in Firaxis used to beat Civilization V (or IV, I forget which) because he had figured out patterns in the random number generator.  That’s a pretty tough threshold to top in terms of “knowing the game”.

But why isn’t AI just inherently better?  After all, I’ve seen a lot of people talk about how good the AI in Galactic Civilizations II is.  And that comes down to how AI is made today versus how it used to be made.

In Civilization IV (and in Galactic Civilizations II) the game designer also wrote the AI including the worker functions.  This meant that the designer knew exactly what the AI would do in various circumstances.  The problem with that is that as games have gotten bigger, it has gotten a lot tougher for the designer to have time to both manage the many parts of the game’s design and find time to write the AI.

In the original Elemental: War of Magic, I wrote mainly the high level algorithms.  I didn’t have time to write the AI itself.  For Fallen Enchantress, I wrote the high level tactical AI and the high level strategic AI.  What that means is that I have the AI call various worker functions like “AIGetAreaThreat(radius)”.

In Civilization IV, Soren Johnson, the designer, wrote the both the high level AI and all of the worker functions too.  That’s very hard core and extremely rare these days.  I wrote the high level AI and the worker functions in Galactic Civilizations II: Dark Avatar and that was the last game I got to do that on (in Twilight, I relied on worker functions written by the team).

The problem with AI worker functions comes down to communication between developers.  It takes so little for an AI to be stupid or to seem stupid.  Let me give you an example of something I worked on this evening:  When the AI decides whether or not a city is defended enough, it calls “AIGetAreaThreat()”.  However, after wiping out the AI one too many times because its cities were poorly defended I decided to look at this function.  It turns out, it wasn’t looking inside enemy cities (i.e. if a city was stationed in a city, it didn’t “see” it).  

I know when I call AIGetAreaThreat() I want to know all the units, not just the units on the map.  But that’s the thing, another developer might think you only mean units on the map (such as in this case).  You add enough examples like that and suddenly you end up with non-ideal AI.

The problem with writing worker AI functions is that they are really…really time consuming.  And AI developers tend to be expensive.  Firaxis got lucky with Soren back in Civilization IV.  But that’s an atypical situation (I think Soren also wrote the AI in Civilization III as well but I could be wrong). 

Now, in the case of Fallen Enchantress: Legendary Heroes, I play the game post-release so I can, in my spare time, update the AI (which is what I’m doing at 9pm on a Monday).  But that’s atypical and could never be economically justified by a studio because, as-is, the AI in these games is typically more than “good enough” for most people.

“Good enough”, of course, is a symptom of a different problem and that is how disposable modern games are and the changes that attitude has had on the industry and how games are made. Smile

182,413 views 47 replies
Reply #26 Top


o
Now, in the case of Fallen Enchantress: Legendary Heroes, I play the game post-release so I can, in my spare time, update the AI (which is what I’m doing at 9pm on a Monday).  

End of quote

I hope you're not back into your old work habits?

Reply #27 Top

Quoting TLamming, reply 22

hmm, I always thought they could build the towers but not do the final spell of creation; I've never lost a game that way. Am I wrong?
End of TLamming's quote

 

Yes it can cast the som. An ai ally did it to me last game

 

Reply #28 Top

Thanks for answering me :) 

 

I hope I am not sounding too ungreatful. I do appreciate the continue'd AI work. I actually like to think of stardock games when I think of good AI. Galciv 2 had my most favorite AI to date.

Reply #29 Top

AI is most vital for ensuring games maintain their value over time- once you figure out an AI, the single-player component of a game becomes worthless to me.

 

(note: AI exploits if avoidable can and should be)- this is why Civ IV provides hundreds of hours of play, and Civ V despite expansions never totalled 100 and probably never will.

 

 

Reply #31 Top

I like these articles about A.I. Interesting.

 

In StarCraft, I believe the A.I was heavily scripted (as it did the same things every single game) but in StarCraft II it was much better. Do any of you guys know what they did to make the A.I better?

Reply #32 Top

look at your CPU usage in SC2 vs SC1 lol

 

that said custom AIs that people have written 10-15 years after Brood War came out use way more CPU and perform much better than the default AIs

Reply #33 Top

I'd still update the GalCiv II AI if I could (the compiler requires Windows XP and that would be a huge pain). 

I enjoy working on AI stuff in the same sense as other people like to play MMOs in their off hours.

Reply #34 Top

Really? You would still update GalCiv 2 if it wasn't a pain? Is the compiler issue the only thing that is stopping you from continuing to update GalCiv 2?

What if someone was willing to volunteer to go through the code so it could compile on windows 7 or something? Mind you when I say that, I don't know how much work that would be...

Reply #35 Top

It would take a lot of effort to move the game from Visual Studio 2003 to 2008 or newer.  It's not worth doing or setting up at this point.

Reply #36 Top

I do IT work based out of Bingham farms, mi. if you ever need someone to set up an XP machine for you (or virtual machine on your windows 7 computer)..lol

Reply #37 Top

So, how good is the AI? My last 3 games in the genre are CivV, Warlock and Eador. I have about 100h in 3 combined because they are just so boring easy. Either I crush the AI or the AI cheats me into oblivion. I'd be willing to pay 50€ bonus to the guy that makes an AI that crushes me in an equal game in my very first campagne in any of the above mentioned games.

 

If chances are I will win my very first game on an no-cheating ai setting, I won't buy my 4th disappointment.

Reply #38 Top

Quoting Frogboy, reply 35

It would take a lot of effort to move the game from Visual Studio 2003 to 2008 or newer.  It's not worth doing or setting up at this point.
End of Frogboy's quote


Well, so much for me volunteering to have a shot at it...

Edit: Wait. Did you think I said that I was willing to try, or that someone at Stardock should do it? I'm not sure if I was clear enough on that point now that I think about it.

Anyways, GalCiv 2 is one of those games that I really liked, a lot. Back in the day when it was still being updated, I would try to thoroughly analyze what ever bugs I found, to try to figure out exactly what went wrong, and try to explain them in simplest terms possible. My reasoning was, the less time you guys had to try to figure out a bug, the more time you guys had to fix bugs and write more code.

I still collect GalCiv 2 bugs from time to time. I'm not sure if you guys still collect them or not (I may have also forgot where to send them), but if you ever want them, they are yours.

Reply #39 Top

Thanks for these thoughts :) Really insightful and helpful into the way that the studios operate :)

 

Has StarDrive wafted into your field of vision?

Reply #40 Top

The problem with writing worker AI functions is that they are really…really time consuming. And AI developers tend to be expensive. Firaxis got lucky with Soren back in Civilization IV.
End of quote

And a "Better AI" mod, they used a lot of improvements for their official Civ 4: Beyond the Sword AI. http://sourceforge.net/projects/civ4betterai/files/Civ4BetterAI%20VANILLA%201.61/

 

Reply #41 Top

Frogboy - if you wanted to, you could allow modding of AI, which allows interested people to help just because they want to, and not because you're paying them money. =)  And it would also allow mod-makers to customise the AI for unique situations not in the main game.

Reply #42 Top

Great post, thanks for sharing that insight. I'd like to think that if you can effectively create AI that trumps most people, you've done a good job. If the marginal cost of improving that AI to trump all people (sans cheating) isn't high, then it's worth improving it to that level. I get the impression it's not that easy from your post! I think what would be great is if developers were transparent about at what difficulty level the AI ceases to improve and they just get cheats to make them more difficult. I don't think the cheating is necessarily a bad way to go. I think if you've hit the limit of how good you can make the AI, then cheating adds an additional layer of difficulty for you to challenge yourself against. When it's not transparent though - you struggle with whether the AI beat you because they out-smarted you or they had an unfair advantage you didn't know about. AI in Civ has always cheated at higher levels, they just may have been more or less subtle about it in any given iteration.

 

For FE (and FE:LH as I'm finding out), what kills me are two mechanics: 1) Pioneer spam by the AI and 2) Monster AI not actively striking at units/cities. I often wonder how the AI manages to create all these outposts and cities around very strong monster lairs. Rarely do I see the monsters eat their pioneers or cities when they should. Any "roamer" from a lair should basically be on a search and destroy mission (you can add a disable for this if you want). They should prefer weaker targets to stronger, but they shouldn't not attack due to a strength differential if they have no other targets. You can limit their search and destroy missions to a certain radius around their lairs. This would give players and AI an incentive to clear lairs instead of dropping cities right next to them and being ignored. For #1, there needs to be a stronger penalty to rapid expansion than what is currently in place. Civ 5 does a great job of penalizing rapid expansion (which you can mitigate) that keeps the game manageable and fun. Would like to see some form of stronger limits on pioneer spam by the AI and player.

Reply #43 Top

The bell curve analogy is fascinating. I can't imagine it being economically feasible to go beyond it in almost any game, but that high end tail would be something to tackle. When I tackle a novel problem it is like magic the criteria I come up with to make a decision on it, if I had to make up a system or some rules or weights I would be restricting the creativity of the mind. People great at a task can give all kinds of heuristics for how they do it, but they also do some intuitive assimilation that fixes all the cracks in the heuristics. We all have experience of that intuition, that answer that doesn't come piece by piece, step by step, but whole from the black box workings of our mind.

This game is nothing like chess, calculation fails to intuition everywhere. To conquer that tail would be to master intuition in AI, and I think that would be far more remarkable than any AI feat done so far.

In fact, I would be willing to wager the AI in LH follows a quote I believe from Jose Capablanca, who when asked how many moves ahead does he calculate, he replied, "One, the right one."

Reply #44 Top

I was hesitant about buying FE:LH when I heard it didn't have a multiplayer mode as the AI in FE didn't really challenge me. But seeing reading about what you've done so far with upgrading the AI motivated me to buy LH. Though it's not much, I just wanted you know that through this you made at least 1 more sale...

Reply #45 Top

Quoting GhostbladeX, reply 44

I was hesitant about buying FE:LH when I heard it didn't have a multiplayer mode as the AI in FE didn't really challenge me. But seeing reading about what you've done so far with upgrading the AI motivated me to buy LH. Though it's not much, I just wanted you know that through this you made at least 1 more sale...
End of GhostbladeX's quote

Thanks!

The v1.3 AI I think people will find a major major step up.  Big thanks to people who post YouTube let's play videos as I'm able to watch how "good" players play the game.

Reply #46 Top

It is my impression that this learn-from-the-players sequence is what happened with GalCiv 2.  Good player techniques were observed, countered, stolen or emulated.  Since the AI is not really an intelligence, but only a set of algorithms for playing the game, clever and aware algorithms lead to clever and aware seeming AI.  We really don't have the capacity to create an AI yet, as part of a game or otherwise, but we can create a convincing illusion for those with a willing suspension of disbelief.  Techniques like yours improves that illusion immensely and I feel that is what leads to the real long term replay value of a Stardock game.

 

Thanks!

Reply #47 Top

Frogboy, regardless of what there is to be said for the AI in your games being good enough or not, know that a journal like this where you give us, your customers, insight into the problems and decisions you face are extremely appreciated. It makes it so much easier to be forgivable about any grievances one might have with a game and sympathize with you as a developer when you open the door to your minds to us, so to speak, instead of being the nameless, faceless overlord I for one unfortunately often come to view a game studio as.

 

It is also a great relief that you recognize that AI is a matter of greatest importance in these sorts of games, and that it is a focus of your further support. Thanks for being such a sympathetic studio, StarDock! I hope you can keep producing quality games so that we may in turn keep filling your coffers - everybody wins!