I’m on Skynet’s side

By on May 11, 2010 1:06:55 PM from JoeUser Forums JoeUser Forums

Frogboy

Join Date 03/2001
+1478

image

This week will mark the second full week I’ve been working on the AI in Elemental.  Beta 1 doesn’t have AI in it per se. It just randomly does nonsense really.

I’ve been writing computer AI now for 17 years (egads). It’s what got me into making games in the first place. I love computer AI.  Everything else in the game (for me) is secondary.

Early AI: OS/2

The first computer AI I wrote was for Galactic Civilizations for OS/2. It had the distinction of being the first commercial (i.e. at retail) 32-bit PC game. The first commercial game to support >256 colors. But for me, the key feature was that it was also the first game to have a multithreaded AI.

Back in 1993, most developers weren’t familiar with multithreading. Games were made with a big WHILE loop.  When a player hit the turn button, they would sit and wait for the computer to make their moves.

In the OS/2 version of Galactic Civilizations, the AI generated their move in the background. This was a key advantage back then because the computing power (think 386SX) was such that most AI had to massively cheat (and I don’t mean money bonuses, I mean play a different game) in order to be challenging.  The AI in the OS/2 version of GalCiv didn’t have to cheat because it received the CPU time necessary to come up with a good strategy.

Of course, my programming abilities at the time were dismal. But thanks to multithreading, I was able to use brute force to make an AI that played reasonably well.

Today’s AI

For me, multicore does’t make quite as much of a difference in AI programming as XML has.  I have previously talked about data driving the AI.  The goal is to move away from hard-coded scripts (whether in Python or C++) and towards XML based state machines. 

The idea is that on reasonably modern computers, the AI can crunch a lot more data to come up with solutions that we humans wouldn’t think of.  Chess programs have done this sort of thing for years but chess boards are very small compared to a game.  With XML based state machines, we can do all kinds of interesting things by letting the AI look at lots and lots of data and look at overall goals that it might have and then make “intelligent” decisions.

Example: Elemental

If you look at the screenshot above, this is an example of an AI driven state machine. The AI was not “told” to build a city like this. Nor was there any sort of (IF I need Food THEN build a farm) type logic.  Instead, it looked at the XML and looked at many different conflicting priorities and determined a course of action which.  The amount of C++ code necessary to get it to intelligent build a city is less than 100 lines (compared to several thousand lines for the craptastic planetary improvement AI in Galactic Civilizations II).

AI Modding

A key feature of having an XML based AI comes in modding.  Modders can make their own AI personalities and drive their own priorities.  After all, the AI can only do what I (the AI developer) thinks is the best way to win. Experienced players may come up with other means.

Now, modding AI is nothing new. In the past, you could use Python or Lua or some other scripting language to write your own AI.  XML driven AI isn’t particularly innovative either, it’s just the sheer level of its use that is a bit different here.

Locked Post 80 Replies
Search this post
Subscription Options


Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 2:20:07 AM from Demigod Forums Demigod Forums

gigaHertz are simply the amount of energy you use 

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 2:44:18 AM from Elemental Forums Elemental Forums

Quoting OMD_Siili,
gigaHertz are simply the amount of energy you use 

 

Isn't that Watt?

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 2:55:12 AM from Elemental Forums Elemental Forums

Quoting OMD_Siili,
gigaHertz are simply the amount of energy you use 

hertz is a measure of frequency, or how many times something happens per second.  1hz = 1/seconds.

Gigahertz=10^9/1seconds.

 

In computers this measures how often the computer's "clock" fires.  A faster clock means you can process things faster.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 3:59:14 AM from Elemental Forums Elemental Forums

Except that for the last several years chip manufacturers have stopped speeding up clocks and have been doing things like adding more cores, cache, or increasing superscalar and out-of-order execution instead. It's meaningless to use gigahertz as a performance measure by saying "my machine is a dual core 3GHz, so it has 6GHz of performance". It's even worse to say "it's 3GHz but it's newer than my 3Ghz pentium 4, so it's actually more like 9GHz total". I don't think aggregrate clocks of a pentium 4 are a good measure of performance. In fact the pentium 4 era is better off forgotten

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 4:16:58 AM from Elemental Forums Elemental Forums

Quoting LeegleechN,
Except that for the last several years chip manufacturers have stopped speeding up clocks and have been doing things like adding more cores, cache, or increasing superscalar and out-of-order execution instead. It's meaningless to use gigahertz as a performance measure by saying "my machine is a dual core 3GHz, so it has 6GHz of performance". It's even worse to say "it's 3GHz but it's newer than my 3Ghz pentium 4, so it's actually more like 9GHz total". I don't think aggregrate clocks of a pentium 4 are a good measure of performance. In fact the pentium 4 era is better off forgotten

 

Was this a reply to me?

It's my understanding that speeding up clocks any further causes way too much heat and draws too much power, also these other changes are having better returns for the expenditure on development.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 4:32:02 AM from Elemental Forums Elemental Forums

I'll be on Terminator's side. The machine which fights the machine.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 4:37:44 AM from Elemental Forums Elemental Forums

This is good news. Elemental sure bringing a big punch for the money. I hope it will be as user friendly as possible (with in the scope of things of-course.

Will this feature be accessible from the editor or it will need more advanced tools to implement?

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 5:57:32 AM from Stardock Forums Stardock Forums

This type of AI will lose to your GalCiv2 AI except you go to great lengths to implement a lot of states. It cant think into the future at all with basic states. 

Lets look at an example of amassing ships at an enemy border in GalCiv2. The AI has a script that recognizes the threat and initiates diplomatic behavior at first. 

State driven AI would need a state to account for that. If it only has a "enemy nearby" state , it probably wont recognize where the enemy is concentrating. The significance of it.

If you want it to recognize that behavior, you'll need to put more code into the AI. So you start to simulate the scripting. You can of-course combine both of the methods and use the better fitting one for a certain case. 

But I'm not a coder and not an AI coder, so IMO.

Am I right?

 

 

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 6:04:54 AM from Elemental Forums Elemental Forums

'This' being the possibility to mod the AI? If it is done in XML then all you need to have in order to mod it is wordpad and some understanding of programming, so the 'more advanced tool' would be notepad.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 6:08:24 AM from Elemental Forums Elemental Forums

Quoting Dudettet,
This type of AI will lose to your GalCiv2 AI except you go to great lengths to implement a lot of states. It cant think into the future at all with basic states. 

Lets look at an example of amassing ships at an enemy border in GalCiv2. The AI has a script that recognizes the threat and initiates diplomatic behavior at first. 

State driven AI would need a state to account for that. If it only has a "enemy nearby" state , it probably wont recognize where the enemy is concentrating. The significance of it.

If you want it to recognize that behavior, you'll need to put more code into the AI. So you start to simulate the scripting. You can of-course combine both of the methods and use the better fitting one for a certain case. 

But I'm not a coder and not an AI coder, so IMO.

Am I right?

 

 
Maybe you are, but I do not understand the question. 'You will need to put more code into the AI.' That is the statement you make. More code than what? More code than juts a few lines that are in right now? Of course! More than just an 'AI_general' state that the AI can be in? Of course. Otherwise each nation would be the exact same in terms of behavior. This is neither a surprise nor is it a remarkable statement.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 7:08:26 AM from Sins of a Solar Empire Forums Sins of a Solar Empire Forums

He means more code in the sense that certain side cases that arn't being handled by the state machine's simplicity will need traditional implementation.

 

Now - I think hes wrong, but then Im assuming Brad* is a good coder by now.

 

Amirite?

 

 

 

 

* and any sidekicks he employs.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 7:30:51 AM from Elemental Forums Elemental Forums

Quoting TarponCrest,
This is good news. Elemental sure bringing a big punch for the money. I hope it will be as user friendly as possible (with in the scope of things of-course.

Will this feature be accessible from the editor or it will need more advanced tools to implement?

You can mod the AI via editing .xml files. It should be easy....even I could mod the AI, and I don't know any coding languages at all. More infos can be found in this topic: http://forums.elementalgame.com/381358

...However if you would like to create a completely new "core" AI for the game -> You must do that in Python.

----

Good luck with the AI Brad. Let's hope that the highest lvl AI will wtfpwn the casuals by the end of the summer.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 8:06:25 AM from Elemental Forums Elemental Forums

Quoting Aractain,
He means more code in the sense that certain side cases that arn't being handled by the state machine's simplicity will need traditional implementation.

 

Now - I think hes wrong, but then Im assuming Brad* is a good coder by now.

 

Amirite?

 

 

 

 

* and any sidekicks he employs.

 

Basically there does need to be no more code. From pure computer science point of view you just need the state translation function.

It is proven that a state machine is completely equal to any code you can write. So basically this means you just really need to define the code, which collects the data which you need for the state transitions.

On the other hand this means you will either have multiple state machines for different AI parts (diplomacy, war, etc.) or you will have an exponential number of states.

The other big question is the performance...so code will work much faster then state transitions/calculations.

But I'am confident that Brad can handle this to our all satisfaction.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 8:26:47 AM from Elemental Forums Elemental Forums

Quoting Tasunke,
I especially like the skewed data on winnable odds. That one makes me smile. Things like resource mal-data, and relations mal-data, feels less necessary yet for me is still welcomed.

Certainly a weaker AI should play with more "character", "personality", "flavor" and less so optimal play exploiting hidden strategies (like the high level AI)

 

+100 to this idea.

 

I'd rather see this then random bad data, though randomness does need to be in any AI to avoid predictability.

 

 

 

 

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 9:10:30 AM from Elemental Forums Elemental Forums

Hmm Stardock created an AI that "can see the whole picture" now i didnt expect anyless from Stardock they always make the best things and take their time its like they have a AI them selves "Take your time > make something awesome" and now with the AI imagine Brad talking to the guys at the pentagon about Comuter AI that would be like...Army learns from game developers well see RTS it good and people can lern from games i mean i learned my English from Stardock's games lol

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 9:20:20 AM from Elemental Forums Elemental Forums

mmmhhhh, scary thread...

 

... I wonder if the AI will send a Terminator back into time to kill me before I buy Elemental. Just to prevent getting beaten by me. And how does the AI know my battlerating ?

 

... Can I send a unit back to protect me ?

 

Best

yti

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 9:25:57 AM from Elemental Forums Elemental Forums

But back to the real AI,

 

I liked the AI personalities from Warlords II. There you could choose not only the level of the AI, but also their playing style (like Atilla the Hun - likes horsemen,etc..). That was really nice and made the AI more human.

Maybe a weaker AI just has some more ticks that arent really usefull (like razes all conquered cities; always max military first or only attacks when 200% certain win chance, etc.)

 

Best yti

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 11:03:33 AM from Elemental Forums Elemental Forums

[quote who="yti.Flash" reply="41" id="2617939"]mmmhhhh, scary thread...

 

... I wonder if the AI will send a Terminator back into time to kill me before I buy Elemental. Just to prevent getting beaten by me. And how does the AI know my battlerating ?

 

... Can I send a unit back to protect me ?

 

Best

yti[/quote]

 

Yes I agree.  Let's not make the AI too good, or it may determine the best path to victory is to kill the person playing the game.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 11:14:46 AM from Elemental Forums Elemental Forums

Quoting LeegleechN,
Except that for the last several years chip manufacturers have stopped speeding up clocks and have been doing things like adding more cores, cache, or increasing superscalar and out-of-order execution instead. It's meaningless to use gigahertz as a performance measure by saying "my machine is a dual core 3GHz, so it has 6GHz of performance". It's even worse to say "it's 3GHz but it's newer than my 3Ghz pentium 4, so it's actually more like 9GHz total". I don't think aggregrate clocks of a pentium 4 are a good measure of performance. In fact the pentium 4 era is better off forgotten

 

1. Why's that?   I'm explaining that my Core 2 Duo 3 Ghz is faster then a 3 Ghz of an older architecture.

2. How can it be even worse to say the 9 Ghz thing..?

 

I don't understand your reasoning....An Intel Core 2 Duo 3 Ghz IS significantly better then a 3.2 Ghz Northwood (P4).

How am I supposed to say it then?

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 11:15:12 AM from Elemental Forums Elemental Forums

But the AI can't win if it has no one to play against ... and other AI don't count.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 12:58:25 PM from Elemental Forums Elemental Forums

Quoting Tasunke,
But the AI can't win if it has no one to play against ... and other AI don't count.

It counts for me.  When I "play" Galactic Civilizations it's primarily to watch the computer players play against each other.

With Elemental, I anticipate other freaks like me to do that since users can define their own AI personalities, assign them to players and then watch them fight it out.

You humans, pah. Frankly, if I didn't need your stinking money Elemental would just be for the computer players.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 1:13:50 PM from Elemental Forums Elemental Forums

Interesting stuff. It's a sad fact that graphics, sound etc has advanced at a much swifter pace than Artificial intelligence in games, or at the least AI hasn't retained parity. I'm confident SD can give us something positively fiendish to play against   at the higher difficulty levels without resorting to ridiculous bonuses to the enemy.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 1:26:19 PM from Elemental Forums Elemental Forums

Au contrair, while AI vs AI might be interesting; the success of an AI is determined by its ability to interact with the human player. (generally with the goal of winning), as with the case of Deep Blue.

The current goal of modern robotic engineers (and robotic AI programmers) is to get a robotic soccer team to play with a human team and win (without killing the human players). This is of course, a long term goal. For now the focus is on getting cars to successfully race against each other on various tracks.

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 1:31:16 PM from Elemental Forums Elemental Forums

The important thing about AI is that it has to be fun to play against.  The hard part is you need AI that is fun for a wide variety of players.

 

some people like nasty AI, some people like easy AI, and some like RP-ing AI.

 

My big thing is I want an honest, good AI, that will RP some at lower levels, but be ruthless at higher levels.  GCII did a good job of this.

 

You need to have room for all three, and this may be the single most important thing to a single-player game.

 

That said: question of my own, how much processing does the AI take in comparison to other stuff?

 

 

Reason for Karma (Optional)
Successfully updated karma reason!
May 12, 2010 1:37:03 PM from Elemental Forums Elemental Forums

Will the AI for campaigns and sandbox mode be different?

Reason for Karma (Optional)
Successfully updated karma reason!
Stardock Forums v1.0.0.0    #108433  walnut3   Server Load Time: 00:00:00.0000875   Page Render Time: