Brad Wardell Talks Gal Civ 2: Dark Avatar AI on IGN

I'm sorry Dave, I can't let you move that ship there.

http://pc.ign.com/articles/750/750725p1.html
One of the most touted features of Galactic Civilizations II: Dread Lords was the artificial intelligence, which can give even the best players a run for their money.  The AI was written by Brad Wardell, who took some time recently to write up some of his thoughts on the AI in the upcoming expansion, Dark Avatar, for an IGN Developer Diary.

It's an interesting look into AI and how technology like the new dual and quad core processors open up a lot of potential for better AI in games without causing noticeable performance hits.  Be sure to check it out!

24,419 views 34 replies
Reply #1 Top
Very exciting developments. The inner workings will always come through, no matter how many layers of makeup they add.

---
Reply #2 Top
If my choice is to play a strategy game online against strangers or against computer opponents that play as intelligently and randomly as human players, I tend to believe I'd probably end up playing mostly against the computer. It doesn't disconnect or swear at me -- yet.


LOL! "It doesn't swear at me...yet" That would be funny to have the AI swear at you in Drengin!

Brad just took out the main Drengin fleet:
Lord Kona: "I hope you rot in QPUTE!!...you Vywrp!!
Brad Wardel: "What did the Develperes put in your mouth? I'll have to fix that!"
Reply #3 Top
A nice piece of text! I think that AI quality can't be brought to attention enough, both for developers and players (often unaware of "good AI" vs. "cheating AI").
Reply #4 Top
Even with my 1.99ghz CPU I am still interested. As it stands I can see AI opponents in GalCiv2 "thinking" even if they still have blind spots and get hung up on things (like having five battleships chasing my invincible freighter half-way across the galaxy and back).
The possibilities in terms of AI is what appeals to me in Turn-based strategy games. Extra system resources can be devoted to AI, resulting in more "thought" and deeper strategies. When I play Civilization IV I don't get the same sense of respect for the AI that I do with GalCiv2. Maybe it is the strategies, or maybe it is just the dialog. I don't know what you did, but you people sure did it right.

In all honesty I would fork over $20 just for an AI upgrade. I wouldn't do that for any other developer.
Reply #5 Top
Thats nice and all. But the reality is that the AI in GC2 isn't really doing a lot of the basic things that I would expect it to. Things that in my opinion don't take a super computer to figure out.

1) planetary management. There doesn't seem to be any solid feedback mechanisms or control of what is being built on planets. Often the AI sits and struggles to build anything since it doesn't decide to quick build a factory. (or manage the build queue what-so-ever) (like building PQ bonuses before other improvements)

2) there also doesn't seem to be any feedback in what planets are building when I start attacking. Building a new transport won't do them squat. When attacked, the AI needs to reconsider everything it's doing.

3) using autopilots deep into my territory is just silly, especially since I can see where they're going. Come on. You need to re-evalulate where those fleets are going on a turn by turn basis.

4) tech research. Is there any solid feedback in what the AI researchs vs what it needs as far as weapons and defense ? (or soldiering) Granted if you get into an extended conflict with the AI, by the time you conqueor it's last planet it will be using a small amount of the right defense... And soldiering, my god if I'm getting clobbered, researching just one soldiering tech can seriously slow that down, but the AI doesn't seem to care about soldiering.

5) Speed. Nevermind here. Supposedly a fix in the works for this. (may have to buy DA to see it though.) This continues to be a HUGE weakness for the AI.

6) Ship design. The AI doesn't redesign, or upgrade nearly enough. Often you'll see the AI popping out ships that are pathetic compared to what it could build. The mechanics of the game are that 1 good ship is better than 50 not quite as good ships. Fix the mechanics, or build the best ship period.

7) Economy. The Ai consistently fails to build a decent economy. (probably ties into why item 6 is a problem.) Look at any decent players strategy, and you'll see plenty of stock exchanges. The AI at most will build a few here and there. (and usually won't even get to stock exchanges on a normal tech speed)

8) Morale. How often do you see the AI do a good job of managing morale ? My 1k troop ships are usually all I need, because of bad morale, and even worse soldiering. Further bad morale generally implies lower taxes, weaker economy.

9) Defending resources. Supposedly it was decided that starbase defenses wouldn't be great, and that a fleet would be the way to go to defend a starbase. Fine, teach the AI this. (or make starbase defenses worthwhile)

What kills me, is these problems shouldn't take a super computer. The AI is amazing in what it does, but it just doesn't play using all the mechanics. I would personally think that just deciding how to move ships around (which it does amazingly well), would be orders of magnitude harder than any of these problems. These problems tend to scale with how powerfull you are, and therefore with galaxy size. I'm personally beginning to think that large/gigantic should be removed from the game. The AI just doesn't handle them. On smaller maps the AI plays much stronger, and these weaknesses are not as apparent. (esp at maso with all their bonuses)

The answer you always hear is, play at higher level. To me that is complete BS. The whole point of GC from the beginning is that AI played fairly. Above maso, for me, I can feel the AI's cheating and it just isn't fun. Before you go talking about how great quad CPUs are, why don't you take care of the some of these basic issues ?
Reply #6 Top
In all honesty I would fork over $20 just for an AI upgrade. I wouldn't do that for any other developer.


I concur. I'll probably forever be a fan of Stardock games, if for no other reason than because AI is so near and dear to Brad's heart. You probably won't find his dedication to improving the AI in *any* other strategy game on the market today, and maybe not ever again.

Now I just have to finally upgrade my bloody machine and get myself a quad-core....  
Reply #7 Top
Sounds interesting but I can't help but notice comments like, and I'm paraphrasing here, "when the majority of my playerbase gets the relevant hardware".

I trawl a lot of strategy game forums and I think we all realise that Brad is seminal in his approach to AI. He IS at the forefront of his craft every bit as much as Peter Molyneux or John Carmack, perhaps more so because their best work now seems behind them.
t
I see a lot of "in the future" comments, which is great but I'd like to know what is definitely in for DA as regards AI improvements. There was a list of "questions that the AI asks" that seems to have been included from the IGN article.

Are these definitely in? Will some of the AI improvements in DA be exclusive to multi-core CPU platforms?

Just to clarify my position: I'd pay £50 for an AI upgrade. Forget the gfx, forget mining, spies, etc., just give me a better AI

Brad: You clearly have you're business head on here, you're differentiating your offering from the market through enhanced quality. There IS a market for this. Keep up the excellent work!
Reply #8 Top
Gal,

I ask again, would you care to name a single strategy game of similar complexity which doens't cheat and does maximize its economy to peak efficiency given heavy change in circumstances? I doubt you can.

And I also have a feeling you have no clue what you are talking about as to how difficult it is for the computer to maximize its build strategy given changes in the tactical situation and given limited cpu ability; weak ships relative to ai tech has been stated over and over again to have been atleast partially a function of hardware limitations.

The only type of person who this would 'kill' would be a childish moron who has never played another single player strategy game and has a truly astounding sense of entitlement.
Reply #9 Top
Whatever. Without addressing such basic issues, you could have 10 super computers running and it wouldn't matter. That was my point.

I never said maximize, or peak efficency. I have a very old computer, and the game still runs hella fast so I don't buy the "hardware limitations" crap. If that's really true, i'd rather they took 30 seconds on the end of turn to do thier thing.

The reality is that the planetary management for the AI is a mess. You still regularly see planets with 4-5 factories, but no starport. (oh, but they do have an orbital fleet manager.) You never see the AI build economy worlds. WHY ? If this aspect alone was fixed, the AI would be much much stronger.

Brad has as much admitted that the planetary management code is a mess. (said he had to completely rewrite it for DA, and the guy who wrote it in the 1st place has left (or fired ? ))
Reply #10 Top
The point is that such 'basic' issues are not as 'basic' as you seem to believe. Building an specialized economic world? That would require the a.i. to have some awareness of the placement of their specialty worlds relative to an evershifting tactical threat; human players can easily defend such intricate planet set ups with their superior tactical ability, the a.i. has no such option.

The reason a.i. planet managment is so generic is because that is the build that brad or the former programmer has taken to work best given other a.i. limitations. Of course, it could always be better, but if it were really as basic as morons like you seem to think it is, it would have already been fixed, and the system wouldn't have had to be built from the ground up for DA.

My basic point is that your dumbass attitude that comes through with 'what kills me' is 'what kills me'.
Reply #11 Top
And might i add that just because you are willing to take a greater amount of time between turns for what would likely be a marginal at best improvement doesn't mean that the majority of players would, thus the need for technical advances.
Reply #12 Top
@gallagher

I think you're not understanding the difference between a new AI algorithm, and how an AI priorities things. The prioritizing is a set of values based on other values, and is a data change. The algorithm (which is the topic of discussion) is the actual development end. You could spend years trying to balance values and still not get them perfect for every given scenario. You could spend weeks writing a new algorithm and a couple more debugging it that would have a noticeable and significant impact right away.

Also, I've done some concurrent programing (in java not C++ like these guys write in, but logic is the same), and I will say that you don't necessarily need dual cores to do AI. Dual cores can really only be taken advantage of in Video rendering, since there is that much data to process, and you do *want* to use as much CPU as possible to get the job done quickly.

In this case, it's more of an urge to the gamers to upgrade their PC's. Not necessarily to meet the dual core standard, but to say, "Hey, look at this awesomely powerful top of the line stuff. That means there is older stuff that is more powerful than most of your PC's, maybe it's time for a budget upgrade."

A single processor has more than enough power (and he admits it) to run all these algorithms. I will say, though, that although hardware boosts can make a sloppy implementation look fine, a properly designed system is fully capable of taking on these tasks at a lower CPU level.

-Singleton design pattern on your thread manager, and possible memory sections that are allocated.
-Allocate fixed memory sizes for different threads.
-Share memory for threads that aren't likely to run simultaneously, avoiding starvation.
-Make sure your threads do not starve in the presence or absence of contention.
-Avoid making everything mutually exclusive. Yes, mutual exclusion improves accuracy on a shared resource, but always ask yourself the "Do the potential race conditions actually affect my end result"
-avoid excess in monitors. Semaphores are implemented by observer-observable, which is much less process intensive
-if applicable, if you can animate your solution and watch it, you may catch starvations you didn't see in the code
-diagram deadlock scenarios. don't waste precious processor power on deadlock detection
-Flyweight Flyweight Flyweight


just my 2bc, not condescending any developers
Reply #13 Top
The answer you always hear is, play at higher level. To me that is complete BS. The whole point of GC from the beginning is that AI played fairly. Above maso, for me, I can feel the AI's cheating and it just isn't fun. Before you go talking about how great quad CPUs are, why don't you take care of the some of these basic issues ?


I agree that the AI can be a little "frisky' when it comes to economy tweaks. I don't know, but they can get a 200% bonus to their economy when put on ultimate. I want them to play better with the resources they have instead of getting morew to work with.
Reply #14 Top
JubJub and Gal,

Simply, put, your standards are too high. It is unlikely any realistic a.i. update will have anything more than a marginal effect on difficulty. For those who do want some challenge the, are resource bonus is perfectly reasonable.
Reply #15 Top
Jasamcarl. Just go away. You haven't said anything of value.

n0v4k4n3, I get what you're saying. Don't get me wrong this AI handles things very well. Especially all the different starting conditions, tech mods, ect that you can throw at it. I have immense respect for what Brad has accomplished.

I personally don't see how some of the highly non-linear aspects of this game can effectively be weighted though. Some things probably just need to be scripted. (like building a starport, parking a fleet on your resources, sometimes quick building a factory here and there, etc)

Like I said before it may just be a matter of improving the AIs planet building skills that will be the key to fixing most of this. I'd love to see the AI at least prioritize what it's building/improving.

Reply #16 Top
Afaik Brad has rewritten the planet build AI from scratch after he fired the dummy who did such a terrible job of it first time round.

Do the latest beta include Brad's planet build AI yet? That should make it worth trying alone.
Reply #17 Top
Actually, since I've heard DA bonus tiles are a lot rarer, that should make for some improving performance in the planet build AI by itself. In lots of cases, yes, it can just follow a basic "script".

However, the scripting still IMHO should be a weighted based on value the item adds to the current planet layout, and value the item adds to what the empire is trying to achieve. (Otherwise they may *never* build the wonders)

The problem with straight scripting a planet build is that there are so many different special cases. Yes, we humans go about it rather methodically in most cases, but sometimes I'll build a research center on a bonus tile then focus on social production when it is completed in order to get what is essentially a factory and a research center out of the first build. There are also the low pq planets that most players tend to make all research. It is a matter of carefully balancing the values, and the only way I can see getting this right is writing a GCII with fighting disabled, and simply watching the AI build up its planets, then repeating the process until most people stop whining.
Reply #18 Top

Few quick answers:

1) Dark Avatar has options for enhanced CPU usage that make use of the new MC_AI (multicore) functions. They will still work even if you have a normal (non dual core non quad core) but you'll end up waiting between turns. Beta 2A has some of this already in actually

In 2A, if the AI has the high CPU option on, you'll see them start moving their ships onto your doorstep before attacking (unlike normal where it'll declare war and you'll sometimes have a phoney war fo rawhile). The extra CPU lets me use algorithsm that involve coordinating groups of ships and focusing them in the right place.

2) The planetary improvement stuff is re-done for Dark Avatar. Which means it'll have its own set of bugs and problems but so far it seems to be quite a bit better. But the underlying..system for planetary improvements (i.e. th einterface I work with) is not something I'm very familiar with and has given me no end of grief.

(i.e. WHY does it build a factory on a research bonus tile sometimes? I don't know. It shouldn't. Half the time good aI is just getting the bloody thign to do what it's supposed to do).

Reply #19 Top
They will still work even if you have a normal (non dual core non quad core) but you'll end up waiting between turns.


Is this *necessarily* true, or is it *likely* to be true? From how you've explained your AI calculation process (or how I understand it anyway), the threads for the AI should finish and sleep on a decent single core CPU if it takes me a couple minutes to do a turn.
Reply #20 Top
They will still work even if you have a normal (non dual core non quad core) but you'll end up waiting between turns.

Though off topic to this immediate discussion, I do have a quasi related question. I received my new Intel Core 2 Duo E6600 PC yesterday. I haven't quite finished setting it up yet, but I'm wondering, is it already obsolete?
Reply #21 Top
gal

actually, i believe you are the one who has said nothing of value. I would have hoped by this point, having been slapped down so many times for your silly fan-entitled jabs at the game, you would have gotten some perspective.

Guess now I'm the one who has been expecting too much.
Reply #22 Top
I haven't quite finished setting it up yet, but I'm wondering, is it already obsolete?


Yes, the AMD quad cores are the top of the line for overall processor power.
*However*, you need to keep in mind that obsolete is a relative term. The quad core technology is really only appropriate for servers. IMHO the dual cores are overkill for a home PC at the moment, because so few applications exceed 10 threads. Besides, there's no need for a dual core with less than 2 gigs of memory, since the net processing power gained by upgrading ram on a single of equivalent power is about the same until this point is reached, and is a lot cheaper. So if anyone has a dual with less than 2 gigs of memory, consider upgrading that machine in the future.

I can't recall a time recently where Intel has had the fastest chips on the market, but they certainly do have the most economical multi-cores at the moment.

That and there just seems like there's something about the Intel assembly language that takes longer to process.
Reply #23 Top
I think most computer equipment is probably obsolete before it is put into production these days.

I don't worry about it too much. I'm still using the system I built in 02 with its 2.4 GHz P4. The only thing I've done to it was up the RAM to 2 gigs last year, and it can run M$ Office programs, Photoshop, .NET Studio, and GalCiv2 simultaneously with no problems.

I'm not planning a new purchase anytime soon, but if there is a radical improvement in AI development based on multi-core processors, I will probably consider upgrading. Because, you know, I have to *cough* work *cough* at home sometimes, and it would help me be more efficient.
Reply #24 Top
obsolete is a relative term

Yes indeed. But literally anything would have been an improvement over what I had. I did go with 2 GB of DDR2 667MHz ram. I can double that to 4 GB at some point and/or goto higher frequency ram.

I think I did reasonably well for $1300. The bleeding edge in performance is so much more expensive and the time to obsolesence is really not that much greater. As an example, I bought a 17.4” 1280x1024 LCD display in 2001 for $1600. As part of my new PC I got a 19” 1280x1024 flat screen for $50 after rebate. I didn’t really need a new monitor and if I did I would have gone with a 21” 1600x1200, but for $50 how could I refuse?
Reply #25 Top
I don't worry about it too much. I'm still using the system I built in 02 with its 2.4 GHz P4.


Yeah, as long as you maintain your windows operating system, extensive power isn't really that necessary anymore. Hardware is getting so fast that developers can't keep up with it... we might be able to if there was a better standard set of libraries available to *everyone*, but companies want to keep their trade secrets.


I think I did reasonably well for $1300.


I didn’t really need a new monitor


Yeah, sounds like what I paid for my system in '04. Although mine is still fairly beasty by today's standards. I agree, I went for that notch right below top of the line... you know, the one where the cost is a tenth but has 95% of the performance. And, you didn't "need" a new monitor, but you may as well have dual monitors to go with your dual core .

Hold up, time out, what was this post about?