Brad Wardell's views about technology, politics, religion, world affairs, and all sorts of politically incorrect topics.
Published on May 10, 2006 By Draginol In GalCiv Journals

Last week I was in south Texas on vacation.  A lot of Spanish speaking people down there.  For years, I've told my wife that for the 3 years I took spanish the only thing I remember is "Donde esta la pluma" (where is the pen).

We were at an ice cream place and the lady behind the counter, having taken someone's credit card said "donde esta la pluma". My moment had come.  My entire life was merely preparation for this one moment.  This was the time for me to shine -- where everything was coming together.

I quickly said to my wife and everyone else in line "She wants to know where the pen is! I KNOW that phrase!"  I finally felt like a big man.

Writing computer AI, on the other hand, is not a fast track to feeling like a big man. I read the AI suggestions people make. And most of them (okay some of them) are well meaning.  But most of the suggestions fall into the "Well duhhh.." category.

The main reason why computer AIs in games tend to suck is that the people programming them aren't good at strategy games and so they can only incorporate their own ideas into it.  Since I'm a strategy game maniac, the limitation has more to do with programming.  I know how to beat the AI at the highest levels in certain circumstances. And it's very hard to get the AI to deal effectively with it when it's playing at the resource level as the human player.

Some people actually believe that the AI should be able to beat an expert player when the AI only has the same resources as the human player.  That's not going to happen any time soon. Not until processors are a LOT faster.  Right now, while the human player is taking their turn, the AI is putting together its strategies. It's adaptive in a given game. But there's only so much that can realistically be done.

One of the most common suggestions is to improve the sensor capability of AI ships.  The problem is, I barely make of sensors on a per tile basis.  Instead, I'll have it scan through ONCE per turn and set various flags on a sector by sector basis.  The reason for that is time.  A given sector has 15x15 tiles.  That's 225 tiles per sector.  That's 73,000 tiles in a huge galaxy.  If a given player has say 300 ships doing their thing and you have 10 players that could be an immense amount of "looking".  That's one reason it's so hard for the AI to get that "first strike" thing.  But there are countless other things like that.

That is why in 1.11 we added a new option (which needs to be renamed) "Intense AI" (that's what I think it should be called later). If that's selected, i'll have the AI make use of new algorithms that do a lot of checking.  I can have the AI do a lot more analysis.  I can have the AI create armadas (groups  of fleets) and other such things that are just too CPU intensive (O^2) for now. Hopefully people have found 1.11 to be somewhat smarter on AI that previously. I will continue to enhance the main AI as well.

The reason why players and reviews praise the GalCiv II AI is that relative to other games, it is quite strong. Compared to some fictious perfect computer player an expert may find it lacking.  But reviewers and players can only compare it to other games to be fair.  And there's a lot there that it can do.

For example, the AI, without having to mod anything, will automatically adapt to user-mad mods. That's one advantage of not scripting it.  You could redo the tech tree, you could replace the units, change galaxy sizes, play on custom maps with custom ships, etc. and the AI will adapt to a varying degree of gaming.  When someone says "The AI is easy when I play on tough on a gigantic galaxy with tight clusters" my inclination is to make tight clusters no so tight rather than putting in weeks of work to try to get the AI to deal with such a specific circumstance.  Realistically, tight clusters on a gigantic map is effectively like saying you want the game to be easier. Which is fine. But if you want more challenge, turn up the difficulty.  Tight clusters allow players to turtle in and build up.    I do have some ideas though for making things more challenging at that specific level.

Still, there's only so much challenge you can have if players are going to hit Ctrl-N until they get some idealized galaxy set up and then complain that the AI wasn't challenging enough when given the same resources when the poor AI got stuck with 1 planet in the corner while the player got set up in a "cluster" with 5 class 15 planets with super-super planet bonuses (yes, we can tell how many times Ctrl-N was pressed in a given saved game).

But I won't get to do AI stuff this week.  I'm currently visiting Microsoft on business in preparation for Windows Vista so my AI coding will have to wait until I get back.

AI programming is my main area.  I wasn't particularly involved on the Diplomacy AI stuff.  I've started getting more involved and will conitnue to start to look more at it.  In the expansion pack, I want to throw in a lot more types of things to diplomacy.  I also plan to change it so that gifts and such give you a set relations bonus that can be limited to stop people from gifting their way to victory (gifts should help but they should be part of an overall package).

So my AI moment will come just like my Spanish moment will come.

When the ice cream lady heard me yipping away she said "Gringo es estupido". I don't know what that means but I assume it means Guy is smart or something like that since I'm sure she was impressed that I knew and announced to everyone that she was looking for a pen.


Comments (Page 1)
3 Pages1 2 3 
on May 10, 2006
Could you re-program my brain, it doesn’t work anywhere near as good as the AI in GC2.
on May 10, 2006
When the ice cream lady heard me yipping away she said "Gringo es estupido". I don't know what that means but I assume it means Guy is smart or something like that since I'm sure she was impressed that I knew and announced to everyone that she was looking for a pen.

Well, I don't know spanish. But google linguistical tools have confirmed what I suspected: "Gringo es estupido" can be translated as " Gringo is stupid" But I don't know at which Gringo she was referring to.

And this link http://www.answers.com/topic/gringo has some nice insights about the meaning of the word "Gringo"
on May 10, 2006
I'm surprised the game didn't have greater mod support sooner, because you're right, an AI which automatically takes into account any change rendered by a mod is a rare and beautiful thing. This is how AIs SHOULD be, opponents which work through algorithms, not scripts. Humans have the advantage that they build scripts from their algorithms and then apply them to familiar situations, which is why we get faster at playing the game.

It's a bit unfair though to lay so much blame at the feed of CTRL-N. Not every CTRL-N is an attempt to screw the AI, often it can be to make things harder for yourself, or to stop the AI being in a screwed position.

You said in an earlier journal that the AIs biggest advantage is the ability to crunch numbers. True. But unfortunately there are some important areas where the AI is failing to take advantage of this by relying on the built-in mechanisms the player users. Take upgrades. The govenor AI will simply build upgrades as and when they become available, in the order they become available. This is rarely the optimal order and a good human player will shit things around as required e.g. moving enhanced factories up if their economy can afford the extra expense, as this will speed up building. Moving better farms down the queue if morale is low and an entertainment center is queued, or if the population isn't near the cap yet...

This is an area the AI should be handling better. Sure, when the number of planets starts to rise this becomes a bit of a processor hit (I'm guessing), but something that the Intense AI could do?

Likewise, as many point out, if you give the AI techs it can't afford to build i.e. Discovery Spheres, then the govenor will immediately start the upgrades on every planet, which in turn holds up any other upgrade for what could be 100 weeks.

People are also still finding the AI building, say, an embassy on a 300% manufacturing tile. I assume this is to do with the way the selection box is moved around a colony, and the AI checks this tile, decides it can't afford to pay for that much manufacturing, and so having covered special tiles now proceeds to let the selection box move through the colony as it normally would, and thus the AI ends up building something else over the special tile. That's a total guess BTW

BTW, will Intense AI be taken into account in metaverse scoring?
on May 10, 2006
I can appreciate being frustrated by people who complain about the game being 'easy' when they do everything in their power to make it easy. I have used CTRL-N maybe three times, and I never use tight clusters because it's lame. I usually turn anomalies down or off, because the constant stream of 2,500bc makes the early game too easy. I slow the tech rate. I also find the game damn hard.

And Quitch, since he mentioned the CTRL-Ns being logged, I imagine that means he's looked through savegames where people have done it a significant number of times. I"ve never done it more than once - I just don't want to start in a corner. I don't scout around first to see how sweet my spot is.
on May 10, 2006
Avatar Draginol :

" That is why in 1.11 we added a new option (which needs to be renamed) "Intense AI" (that's what I think it should be called later). If that's selected [...] "

Where is that new A.I. option selected when starting a new game with version 1.11 ?

Does anybody know ?
on May 10, 2006
If the computer players used as much time as the human to plan their work, I'd imagine CPU cycles wouldn't be such a big deal. Of course you'd probably have trouble selling the game.

Thanks for caring.

on May 10, 2006
This article was a trick! It started out about being on the road and then it went all technical. Hmph....


Have a good time in Washington!
on May 10, 2006
Perhaps a gift should only increase one level of relations eg warm to friendly once every two years. Also the needed amount of the gift should be relative to the strength of the empire in question poss economically. eg if you gave 50 quid to a tramp he'd love u forever if you offered a 50 quid bribe to a multi millionaire it would likely pi$$ them off.

Lenius.
on May 10, 2006
Hi Draginol,

I like to say that I appreciate all your comments on developing the AI in GalCivII as I have (and still am) studying AI to varying degrees for the last few years, and all this information is very enlightening. I think most of the problem comes from people expecting that AI to be smart - but even in Chess, there's not a 100 percent chance that the computer can beat an expert human player. The limitation also stems from time, and processing power.

Good work and I hope you will continue to create algorithm that will move AI forward in strategy gaming.
on May 10, 2006
Brad, I have a stupid question. What is the optimal setting for the AI? I notice you mentioning all the things that the AI doesn't do well all the time, but you never really seem to mention what it does do well. I would like to know, so that I can play in that setting. I have played in all sorts of settings (You can see that by looking at my Metaverse scores), and it seems that the AI does the best in smaller maps with few opponents. However, I would like to know what you feel is the best setting for the AI to do well.
on May 10, 2006

It's a bit unfair though to lay so much blame at the feed of CTRL-N. Not every CTRL-N is an attempt to screw the AI, often it can be to make things harder for yourself, or to stop the AI being in a screwed position.

I can only go by the saved games that get sent to us.  Nearly all of them have the AI crippled in some tiny spot while the humans are in some rich cluster.

If you're playing on huge galaxies with tight clusters then it's really not likely to be a "fair" game.  I personally enjoy tight clusters but I also turn up the AI behind "tough".

on May 10, 2006

It's a bit unfair though to lay so much blame at the feed of CTRL-N. Not every CTRL-N is an attempt to screw the AI, often it can be to make things harder for yourself, or to stop the AI being in a screwed position.

I can only go by the saved games that get sent to us.  Nearly all of them have the AI crippled in some tiny spot while the humans are in some rich cluster.

If you're playing on huge galaxies with tight clusters then it's really not likely to be a "fair" game.  I personally enjoy tight clusters but I also turn up the AI behind "tough".

on May 10, 2006
To me the problem with AI has always been the fact that it is a black box. It sees nothing more than game data. That ability causes the developer to have to handicap it. So, it either comes out feeling as if it is reading your mind, or is overloooking the obvious.

We react the way we do based upon our senses. We "think", and the computer "knows". Building AI into a game like Pong seems like it would be easy, but it's like the simpler the project the more difficult the problem of making the game behave in human terms. It, of course, knows where the little square is headed, since it is the one sending it there based upon user input.

I've been pondering it a lot lately. I think great strides have been made placing the AI in a user space apart from the game physics, for example. Now we see games giving wants and needs for the AI to react to, and I think that is vastly superior than just reacting to player stimulus.

In terms of really filling the whole psychology out, though, I think we have to deal more with how people think. How they make their associations between their needs and the real world. When I get hungry, a jillion things are at work associating that need with the possibility of formulating a sandwich and sticking it in my mouth.

I played around with neural networking and such and to me it gives more of a "feel" for the computer reacting and learning as opposed to real acting and learning. The way a computer puts together the cause to an effect would be vastly different than how a person does, since we are using different hardware and senses to formulate the act.

I'd like to see more done with natural AI. Give the agent the tools it needs, and then see what kind of associations it makes on its own. The answer to me isn't so much teaching a computer to think like a person, but bringing computer thought to a level that reaches human capacity for reason through its own semiological constructs.

The concept of "sandwich" doesn't mean anything to it unless we program in a need and then force an association. The key to the future of AI, in my opinion, is that tertiary layer of association that tells us what to do based upon our needs and what we have available to us. In order for those reactions to look natural, I think we'll have to allow them to occur naturally.

That probably didn't make any sense at all. I'm a sad layman in terms of the meat of it, but I just think the computer needs more than just "the programmer told me to" or "that's where the little square is going to go" in order to really function like a player.
on May 10, 2006
I'm glad a developer has finally come out and taken and (polite) swipe at the half-assed, ignorant condescending 'suggestions' that many posters typically lob at the forum.

So, let me give some poster here some basic example of good and bad feedback, and especially the AI:

"The AI does not handle starbases well; this is why." - Good
"The AI doesn't hand starbases well: THIS SHOULD HAVE BEEN FIXED!! IT'S SO EASY!!! YOU DEVELOPERS SHOULD KNOW YOU HAVE A LOT OF WORK TO DO!!!" - Bad

For those who still don't get it, commenting on the game you have, your perceptions of its performance, and your opinion of how fun it is. Some faults, especially relative to other games - good.

Making the issue personal, either through direct attacks on the developers competence, or through condescending passive aggressive 'advise' in which you pass off your blatantly obvious 'insights' as some type of sage advice. - Bad
on May 10, 2006
O^2 operation? Maybe you need to use something like the following for finding all the ships near a given point.

http://www.ddj.com/dept/cpp/184401449

Setup time for the data structure is proportional to (nlog n) (only needs to be done once at the start of the AI's turn).
Actual search time is proportional to (log 2)(log n).
3 Pages1 2 3