Frogboy Frogboy

Elemental: AI designing

Elemental: AI designing

image

For those of you not familiar with game development, most of the development is spent designing the engines and technologies that will be used by the game. In our case, about 2/3rds of the time is spent on that kind of thing. 

In many respects, this time is much like developing a traditional software application.  Elemental uses a graphics engine that has been developed over the past couple of years for Society.

Our previous games used an engine called Pear that was developed in the late 90s and enhanced over the years.  The new engine, called Kumquat, has all kinds of goodies (as you'd imagine).

One of the big differences in Kumquat from my personal coding perspective is its use of Python for scripting.  Our old engine wasn't scriptable so everything was written in C++.  Now, Stardock is a bit unusual that we don't tend to use scripts in our games. In Elemental, the only reason we're using scripting is to make it easier for other people to mod the game.

Anyway, now we're starting to put the pieces together to actually make "the game" as opposed to a series of technologies.  That means I finally get to start sinking my teeth into AI.

With Galactic Civilizations, I only got a couple of months to work on the AI and I had to do it basically on my own.  This time around, our team is large enough that I get to work on it longer and I have help.

Not that I don't mind writing functions like get the distance between two points or whatever but having others who can write the worker functions will save me a lot of time.

One other difference in Elemental was the decision to have multiplayer support. There's a single player reason for this - I want to see how people play the game before the game is released so that I can incorporate clever strategies into the AI.

Those of you not familiar with Stardock developed games know that from my personal perspective, the only point to these games is the AI.  Personally, I think it's great that humans want to play the game too but I'm in it for the computer players.  My fun on GalCiv was always watching the different AI personalities fighting each other to see who would win.  But then again, I'm a pretty weird guy.

114,203 views 67 replies
Reply #51 Top

Now we're up to horses? Where did horses come from?

Reply #54 Top

good read!

Reply #55 Top

I think the horses conversation stemmed from the Unicorn conversation we had in another thread.

Reply #56 Top

I know nothing about AI programming and very little about video games, so forgive me if my question is stupid :

Why not allow the AI to "think" longer before playing ? I play computer chess, where there is a strong correlation (although not linear of course) between the program's playing strength and the amount of time its computes before playing. Wouldn't that work in strategy video games ?

I wouldn't mind waiting one or two minutes before the AI plays (for late-game turns at least).

The program could also compute while the human player is playing (many things on the AI side seem independent from what the human player does ; or it could try to guess what the human player will do, as chess computers do). I know it takes me a long time to play, so the AI would strongly benefit from that.

Reply #57 Top

Quoting Wittgenstein83, reply 6


The program could also compute while the human player is playing (many things on the AI side seem independent from what the human player does ; or it could try to guess what the human player will do, as chess computers do). I know it takes me a long time to play, so the AI would strongly benefit from that.

I don't think we need to concern ourselves with it, but your suggestion about the AI being able to come up with better strategies the longer he player takes to do his turns would be bad news for anyone who likes to consider what they're doing.  If it did work that way everyone would be worried about taking too much time to complete their turns.

Reply #58 Top

Quoting KellenDunk, reply 7

I don't think we need to concern ourselves with it, but your suggestion about the AI being able to come up with better strategies the longer he player takes to do his turns would be bad news for anyone who likes to consider what they're doing.  If it did work that way everyone would be worried about taking too much time to complete their turns.

If I'm not mistaken, GC2 did do something like this (or they talked about maybe doing it, at least) - most of the AI actions were calculated during the player's turn. And it needn't be "bad news" for anyone who takes long turns. For one, most would enjoy the challenge, and secondly AI competence would still ultimately be limited by the difficulty level. For example, if you leave an Easy AI for 10 minutes it's not going to turn into a harder AI - it is fundamentally limited by its difficulty setting (easy AI doesn't have access to the same, better, algorithms that harder AIs have). Having longer to take turns could just mean AIs can consider more things more thoroughly and act a little less predictably, but its decisions wouldn't necessarily be of a higher quality.

Also, you don't really want even easy AIs to act as if they're just clicking things at random - ideally you want them to act as a bad or beginner player. Having more time for the AI to figure out what to do could potentially help get rid of some of those nonsensical actions that pretty much only a bad AI would ever do. I also don't know that much about AI, so I could be wrong about all this...

Reply #59 Top

If I'm not mistaken, GC2 did do something like this (or they talked about maybe doing it, at least) - most of the AI actions were calculated during the player's turn.

That's essentially why AI in turn based game tends to be quite considerably superior than in real time strategy games.

In a TBS, the AI has, for all practical purposes, an infinite amount of time to decide what to do - the player's turn. In an RTS, all the calculations have to be done in real time at set intervals which greatly limits the AI's potential. It just can't be complex enough because it needs more time and more resources than it's able to get.

Reply #60 Top

Quoting Wittgenstein83, reply 6
I know nothing about AI programming and very little about video games, so forgive me if my question is stupid :

Why not allow the AI to "think" longer before playing ? I play computer chess, where there is a strong correlation (although not linear of course) between the program's playing strength and the amount of time its computes before playing. Wouldn't that work in strategy video games ?

I wouldn't mind waiting one or two minutes before the AI plays (for late-game turns at least).

The program could also compute while the human player is playing (many things on the AI side seem independent from what the human player does ; or it could try to guess what the human player will do, as chess computers do). I know it takes me a long time to play, so the AI would strongly benefit from that.
Chess programs are more like search engines , thus they look at all possible moves :1 ply( to keep it simple let's say there are  20 possible moves), then all replies to the first moves 2 ply (20x20 =400), then all those replies 3ply (8000) , 4 ply (160,000), 5 ply (3.2 million), 6 ply (64 miliion), 7 ply (1.28 billion), 8 ply (25.6 billion),etc. If you have a 3 GH processor then it takes a little over 8 seconds to see all replies 8 moves ahead.

 Also the chess program pick it's calculated "2 ply" move  from it's list as your next move then start searching it's next reply during your turn. If you happen to pick a different move then the search engine has to start over as all the calculations done during your turn are now useless.

Since most TBS has tons of more options then just moving one piece per turn (diplomacy, resources, building more units for example) as well as luck (chess battles are absolute) a chess AI search engine  isn't very useful in other strategy games.

  Just for example let's increase the most possible moves  for each turn to 100. For a 3 GH processor to search every possible reply 8 moves ahead it will take a little over 38 days.

Reply #61 Top

Brad,

  Have you thought about using Mono instead of Python? I saw that is what Sims3 is doing.You get a speed bump and can use C# or VB or ... that way. C# is also closer to C++ than Python is.

  You'd also get a much better debugging expreience for the lead developer that way by doing the initial programming in Visual Studio for .Net 3.5.

  There is a library called mono add-ons or something like that which makes deploying the add ons as simple as dropping the C# files into a folder.

  Also, Mono is getting closer to Beta for a Visual Studio add on to compile mono direclty in VS instead of compiling to .Net while developing, then switching to Mono for deployment.

  Let me know if you have any questions about this approach, and I'll try to hunt down the resources.

 

Reply #62 Top

Quoting RalphT, reply 11
Brad,

  Have you thought about using Mono instead of Python? I saw that is what Sims3 is doing.You get a speed bump and can use C# or VB or ... that way. C# is also closer to C++ than Python is

Regardless of any advantages Mono may or may not have over Python, I'd say it's pretty safe to assume that the development process is way too far to switch languages - at least for Elemental. Additionally, it being close to a beta stage is not going to help Stardock, because they are working now...

Reply #63 Top

A bit off-topic, but...what we really need is for some computer scientists out there to get languages beyond the never-fully-realized promise of SmallTalk and Lisp.  Someday...

Reply #64 Top

A bit off-topic, but...what we really need is for some computer scientists out there to get languages beyond the never-fully-realized promise of SmallTalk and Lisp.  Someday...
 

They're undoubtably already out there, but having a language out there with one reference implementation of a compiler is a vast world away from having a language capable of production level work with an IDE, debugger, multi-OS support, etc, etc.

Reply #65 Top

Mono is great, but Stardock are a Windows shop, so I guess they won't be using it. Incidentally I believe they already make some of their other stuff (like Impulse) in C#.

Every programmer has their favourite language I guess. Myself I think Scala would be very productive for this sort of thing. It's still possible, though, to make cool things with crappy languages (how many of us started with Basic?), so I can hardly object to having to learn a really cool one like Python.

Meanwhile..."the never-fully-realized promise of SmallTalk and Lisp"..."a language capable of production level work"...Javascript anyone? Ok, some of the syntax is kind of ugly, but Javascript is ubiquitous, has all sorts of tools for analysing and debugging your code, fast implementations, and is ridicuously flexible. People see it as a toy for making a navigation bar for a website, but it has the potential in it for some really dark magic.

Reply #66 Top

Javascript? *shudder* 

I've worked in C, C++, Java, even some PLM and Javascript was worse than all of them, except PLM :).

Javascript has horribly funky ways of handling inheritance, method overriding, etc. If you're going to use a general purpose scripted language with OO support, use something like Groovy (or, obviously, Python). Haven't used Scala, but it might work just as well.

I sort of wonder about Python's longevity for big projects since it does some weird stuff, like the fact there aren't any truly private variables in a class...their names are just obfuscated to prevent namespace conflicts. But, it's been around a while, so it has to have something going for it.

Reply #67 Top

Javascript is incredibly powerful--I agree it's far more than a mere web-page toy creator--but it's not truly object-oriented, and isn't close to human semantics.  Lisp's definition is written in Lisp, for goodness' sake: that's powerful semantics.