Frogboy Frogboy

The lazy AI developer

The lazy AI developer

The AI in Galactic Civilizations I and II has tended to get a lot of praise over the years.  But it could have been better. Much better. 

A big reason that kept it from being better was sheer laziness on my part.  A lot of the best strategies involve algorithms that just are tedious to write.

For example, I submitted feedback to GPG for Demigod’s AI based on algorithms I knew would be effective but that I didn’t actually use in GalCiv because they were a pain to write.

My favorite example is a pretty straight forward algorithm: What is the strength of an enemy in a given area compared to mine? You provide the unit in question and a radius and it returns a value based on the relative damage potential of other things in the area and from that you can decide whether to move forward or not. 

It’s a great way to mobilize units together as a cohesive mass. In Demigod, it would tend to make the AI less likely to go into harm’s way.  This is one tiny example and each tiny example on its own is easy to write but taken together, they mean a lot of work that I wasn’t able to get to (or didn’t want to get to) in Galactic Civilizations.

In Elemental things are different.  Oh, I’m still lazy. Dangerously lazy.  But now I have Charles to work with who helps split the work on this stuff.  On our previous games, I wrote the AI myself – The Politial Machine, GalCiv, Entrepreneur, etc.  This time, I have a small team to help me with it.

Part of that is because the AI in Elemental is a very big deal. People are excited about the features of Elemental but to me, those features are meaningless unless there are computer players that make good use of those features. Or more to the point, intelligent use of them.  While Elemental will have multiplayer (up to 32 people for starters), the focus of the game is single player. That’s the part of the game I want to make sure we absolutely nail and for that, it absolutely must have intelligent computer players.

Over the past 15 years I’ve built up an increasing library of algorithms I’ve doodled together for how computer players could play more like expert humans. Elemental will be my first real chance to see them come to life. I’m very excited.

124,802 views 60 replies
Reply #26 Top

Lies, humans over AI!! DOWN WITH SKYNET!

Reply #27 Top

Frogboy... lazy?!

:rofl:

Reply #28 Top

Exciting for us too!

In your Questions for July thread I had posed some questions about the upcoming work on Elemental AI which I hope you will answer at your convenience. In the meantime, may I ask about a fundamental AI concern with Elemental? It seems that your job with the AI gets easier the fewer numbers of variables are involved; thinking about the undercomplex combat system in GalCivII, for example, and the strategic map's lack of chokepoints and movement lanes, I can imagine that this helped you to a great degree. But Elemental, I hope, will be different; at the very least, the terrain will have a lot more variables to consider. And I hope that the implementation of a magic system will effect the number of real choices a player, AI or otherwise, need make every turn; I am further hoping that the combat system will on the one hand have some sort of system of checks and balances (e.g. piercing, slashing, bludgeoning damage being optimal / suboptimal vs. different types of armors, cold/heat and elemental resistances, and on the other hand a more complex system which involves both hits / misses in melee and missile as well as a unit's statistics such as dexterity and strength, so that spells which effect a sovereign's abilities could also affect those of her armies -- not merely XYZ damage vs. PQR hitpoints).

Will all of this entice you and help awaken the slumbering dragon of laziness, or does it seem daunting and hence, because of its challenge level, to be avoided as an AI-programmer's nightmare?

thank you for your time

Reply #29 Top

Quoting OsirisDawn, reply 23



Quoting Denryu,
reply 21
Frogboy a question I have been wanting to ask about GalCiv AI and since you brought it up...

Were there significant AI changes between GC 2 and GC2 TWOTA? The reason is I did not buy TWOTA for the longest time thinking "How much could they have changed? How could it be worth the price?" Honestly if I remember correctly I ended up buying it to improve my odds at an alpha slot, lol.

Anyway, it seems like the AI is much better in TWOTA, it seems less predictable and seems to come up with more human-like responses. and seems to evaluate what I am doing a lot better. Then I thought wouldn;t it be funny if the AI didn't change or was minimal and I am just imagining it. So would you settle it for me? Were there major changes to the AI between GC2 and GC2: TWOTA?

And all I gotta say is that if you are planning on going well above the GC2 AI, that will be something to see!



I know only one thing: Since TWOTA i cant beat the AI but on its lowest level. I suck that much, yes.

But before TWOTA i could beat it on normal (sometimes    ) .

I noticed the same thing. Normal used to be an OK difficulty and I could beat it a good part of the time playing in a non micromanaging and somewhat laid back game. After TWOTA it seems like I have to be very much on my toes to win on Normal difficulty! And the AI seem to be much more aware of what I am trying to do and works appropriately (as a human would) to foil my plans!

And when I first started playing TWOTA I could only beat on the easiest as well! But I had a few AHA! moments when I would learn a trick or two that made a huge difference.  But I don;t even want to try anything harder than normal, I would just be asking for an embarrassing spanking.

Reply #30 Top

I used to regularly crush the AI on challenging without a massive amount of micro.  Then I got TotA and got smashed doing the same thing.

Reply #31 Top

Oy! Programmers are not lazy!

The term is 'constructively idle'.

Reply #32 Top

Well, I guess I don't need Frogboy to respond. :'(   Enough other people are indicating similar experiences that I will just take it for granted that the AI had a major overhaul between GC2 and GC2:ToTA.

 

And sorry for referring to it as TWoTA - I normally acronym things properly, LaOL. ^_^

Reply #33 Top

Quoting Nights, reply 31
Oy! Programmers are not lazy!

The term is 'constructively idle'.

I thought being lazy was a job requirement...) -_-

Reply #34 Top

XD lazy ya ya... but in that time your thinking up all the good stuff! Can I bug ya whens next patch? or Beta 1a? :drool:

Reply #35 Top

Not so much lazy as needing motivation :)

Reply #36 Top

Over the past 15 years I’ve built up an increasing library of algorithms I’ve doodled together for how computer players could play more like expert humans. Elemental will be my first real chance to see them come to life. I’m very excited.

As someone who plays 4x games almost exclusively single player, with the occasional hot-seat game with 1 or 2 friends and a load of AI players, I also am excited.

Reply #37 Top

AI programming is one of my favorite things. It is fun to see computer players doing all the work for you after you have tweaked stuff.

And imo it is really not the most important thing to have the AI play very well but instead the most important thing is that it plays interesting and varied. Back when Warcraft 3 came out I started AI modding because the AI was so boring, always doing the same thing. But the problem was that a lot of the AI was hidden in hardcode instead of in accessible script and the tools to alter the AI script were nonexistant in the start which resulted in a lot of extra work to get a system you could properly use. Ever tried programming when all you get as feedback is if it runs or not and no information about if it is a syntax error or a runtime error and no idea about where in the code?

So I hope that for Elemental most of the AI will be in the script and in an architecture that makes extending and tweaking easy :)

Reply #38 Top

Quoting ckessel, reply 35
Not so much lazy as needing motivation

But isn't a certain laziness part of a good dev's motivation, at least when it comes to automating un-fun repetitive tasks?

Reply #39 Top

Frogboy, how are you going to have time for great AI when you're working on that book?  :P

Reply #40 Top

In college I became very disillusioned with AI. I had all these ideas about computer learning and dynamic code and neural networks and really none of that amounted to much of anything.

You basically had expert systems (bleh prolog!) that only work in very abstract controlled environments and (tree)search. When I learned that the best chess AI was nothing more than look up tables with opening/closing plays combined with just brute force game tree traversal I became saddened. To me such "AI" was identical to just pre-programming in an answer to a problem. Having a computer just explore a game tree is beyond dull and nothing at all like intelligence or emergent behavior.

The most exciting stuff I read about came from Rodney Brooks and the subsumption architecture. The idea that complex actions are the result of many trivial responses is fascinating to me. Implementing some basic forms of it in lego robots and getting inscet like behavior was very cool. It was not enough to keep my interest in the field as a career but AI remains as something I keep wanting to see done "right".

I am looking forward to seeing the AI in Elemental evolve from the ground up. I would also like to strongly second the call for modding hooks when possible. I doubt it would work well but it would still be fun to build an AI based on some of Brooks' ideas.

Reply #41 Top

Quoting SnallTrippin, reply 24
...question: Aren't all programmers lazy?  Answer: ye

 

Heh, one of the quotes I use at work:

Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.
-- Robert A. Heinlein

Which I typically follow with "So they don't have to get up as early"

 

I never cease to amaze myself with how much effort I will spend to save a couple of minutes off of a tedious project.

Reply #42 Top

Haha, that's a good point actually - I spent hours programming maths appliations on my graphical calculator at school that would basically do my work for me to save myself the trouble. The hard part is, of course, getting it show the workings out, but I managed. I think it probably took more time and effort to do that then it would have taken to actually do the work, but it saved countless other kids hours of hard work... and probably destroyed their maths education in the process.

Reply #43 Top

By premise the AI can´t be smarter than the analysts/programmers that developed it, can it?.

Well, I only hope the AI will be also less lazy than Brad. ;P

 

 

Reply #44 Top


My favorite example is a pretty straight forward algorithm: What is the strength of an enemy in a given area compared to mine? You provide the unit in question and a radius and it returns a value based on the relative damage potential of other things in the area and from that you can decide whether to move forward or not. 

In my opinion the issue is not so much the complexity to code the algorithms but the amount of time they require and then how to handle fuzzy/incomplete information.

I did something like the above example in my own game a while ago, where I computed power projections and had a map of power projections that could be used to decide whether or not it was safe/useful to go into a certain area. The data was incomplete because there were some factors that couldn't be easily evaluated, but the real issue was what happened when fog of war hid a unit. You have to somehow remember that a unit has been seen there and thus the threat is higher than expected, until you actually see the same unit the other side of the map, (but how can you be sure it's the same unit)...

Keeping in memory all the relevant data and checking it for each player tends to be computationally expensive when there are many units, which calls for astute coding if you want the game not to slow down too much as number of units grows.

Reply #45 Top

In Elemental things are different. Oh, I’m still lazy. Dangerously lazy. But now I have Charles to work with who helps split the work on this stuff.

Sweet, I got an honorable mention.  :grin: :beer:

Reply #46 Top

Quoting LDiCesare, reply 44

In my opinion the issue is not so much the complexity to code the algorithms but the amount of time they require and then how to handle fuzzy/incomplete information.

I did something like the above example in my own game a while ago, where I computed power projections and had a map of power projections that could be used to decide whether or not it was safe/useful to go into a certain area. The data was incomplete because there were some factors that couldn't be easily evaluated, but the real issue was what happened when fog of war hid a unit. You have to somehow remember that a unit has been seen there and thus the threat is higher than expected, until you actually see the same unit the other side of the map, (but how can you be sure it's the same unit)...

Keeping in memory all the relevant data and checking it for each player tends to be computationally expensive when there are many units, which calls for astute coding if you want the game not to slow down too much as number of units grows.

In a turn based game that should not be that much of a problem, especially since you can do a lot of computation while the player does his turn.

For a unit which is afterwards hidden by a fog of war I'd suggest diffusing the power depending on the speed of the unit and with the fog of war borders as walls.

Reply #47 Top

One of the things mentioned while speaking with a certain someone was this...

"I got into making games because I wanted to write AI.  I'm rooting for the computer, I want it to win... Other guys write AI because they have to.  So they kind of half-way write AI."

(mind you... these aren't the exact words spoken, but the general idea comes across.. )

Reply #48 Top

In a turn based game that should not be that much of a problem, especially since you can do a lot of computation while the player does his turn.

Unfortunately that's wrong. Play Civ (any version) on large maps on an average requirements machine and you'll see that turns take a lot of time to compute.

Reply #49 Top

I'm still hoping that Elemental will see "a certain someone" spread his interests to include AI that is 'on staff' for the player as well as running a strong civ all by itself. Maybe the vassals will be a good starting ground, and eventually we'll get royal councillors who can truly handle some delegated responsibility without too much risk of them abusing their authority.

Reply #50 Top

Quoting LDiCesare, reply 48

In a turn based game that should not be that much of a problem, especially since you can do a lot of computation while the player does his turn.
Unfortunately that's wrong. Play Civ (any version) on large maps on an average requirements machine and you'll see that turns take a lot of time to compute.

Well, of course you can always use up any amount of computation time if you wish to. It depends on what algorithms you use and how much of a brute force approach. But compared to RTS, you have a lot of CPU cycles free for AI.