When I wrote the AI for Galactic Civilizations, everything was hard-coded in C++. That was nice for me but not so nice for everyone who would like to tweak things later. Moreover, it makes it very easy for things to become a mess later on as improvements rely on my memory of what technique I used to do a given thing.
Yesterday and this morning, I officially began my work on the Elemental AI. What’s in the game presently isn’t AI, it’s just a few IF/THEN statements. My job is to design and code a structure that allows the computer players to play intelligently and provide a challenge without having to cheat.
So…how do you start?
The first step is with XML. You can do an awful lot just by defining lots and lots of “stuff” in the XML.
First, I start by defining AI personalities. My starting point is AI_General which is, as the name implies the general AI personality that I’ll start from. When I’m done, modders will be able to go in and define their own AI personalities that behave completely differently.
Here’s an example that I whipped up last night.
I define some Priorities (Economy, Farming) and I define some things I want the AI to avoid (War, Construction Times, etc.). Now, as I get better at this, I’ll tie together these definitions throughout all the game data.
So for instance, items that are tagged as Economy and Farming by the “AI General” will get their priority multiplied by 3.0X and 5.0X respectively. Someone else might come along and make AIPersonality=”RavenX” and have a totally different set of priorities. When the game starts, it’ll eventually look for all the AIPersonalities and grab them for the different AI. We might even let people from within the game pick which AI personality they want (not in 1.0 but eventually).
I’m a n00b
I’ve been using XML for years for skinning purposes but I’ve never tried to data drive an AI before. It’s not hard, but there is no substitute for experience. So over time, it’ll get better and better so that less and less of the AI is actually hard-coded and what requires “real” coding would be provided as Python.
Eventually, we will also have all the AI difficulty levels clearly defined so that players can adjust them far beyond what you could provide in the game UI.
BTW, feel free to shoot off your own ideas on this. My “AI skillz” largely revolve on producing macro-level systems for intelligent artificial players. Implementation is not something I am passionate about so don’t feel like you’re stepping on my toes by suggesting different implementation techniques.
Please, please keep it simple, easy to read and consistent! I am a complete novice when it comes to editing XML, Python and C++, but in my recent forays into Civ4 modding, I find the XML the hardest to deal with, particularly when you have elements that span several pages and tags that aren't intuitive due to their uninformative names!
I've been doing a bit of searching on AI's that learn/adapt, and there's a few sources out there. Unfortunately some of the best I've found (so far) are compilations of articles (their abstracts sound great, but without reading the articles it's impossible to know if there's any/much meat in them) -- http://www.aiwisdom.com/ -- or is subscription-based -- http://fear.sourceforge.net/
I did find an interesting article http://www.cse.lehigh.edu/~munoz/Publications/AIPG07.pdf titled 'Game AI for a Turn-based Strategy Game with Plan Adaptation and Ontology-based retrieval', which used HTN and CBR/CBP on Call to Power 2. Kinda interesting article but more theory than how-to.
Then I found an article that sorta built upon the first article -- http://www.aaai.org/Papers/AIIDE/2008/AIIDE08-027.pdf 'Adaptive Spatial Reasoning for Turn-based Strategy Games'. These folks came up with a simple game, and in experiment 1 (Iterative learning) constructed an AI (basic all-out rush) then had an adaptive AI play against it, learning, until the adaptive could win. Then it used that AI as the opponent and had a second adaptive AI play against it, etc., until they had 10 AI. Turned out there was no clear winner vs. all the others. The 10 AIs strategies fell into 3 general categories -- rush enemy bases, defense (keep units close to home and only attack when provoked), and unit offense (a rush but toward enemy units not bases) that were sorta rock-paper-scissors against each other.
Experiment 2 was Multi-Objective Learning, trying to find an AI that could handle all 3 general strategies. They "generated 28 non-dominated individuals", one of which "outperforms the other AIs by a large margin", "The average fitness it achieved was about 25% higher than that of the next best individual in this test". This individual developed a fourth strategy -- holding its unit back until enemy units approached then sending all its units at the enemy, giving it initiative and a numbers advantage.
Amongst their conclusions "This behavior shows that the learning algorithm is able to generate an AI which not only outperforms multiple tactics, but does so using a new, somewhat more complicated tactic, instead of an improved version of the previously generated tactics".
Granted it's a simple game and their strategies are pretty simple, but it's still an interesting read, and anyone interested should read it themselves and not rely on my characterization.
The question of whether it's possible to use this sort of AI in Elemental, given constraints of time/resources/etc. is a good one. I'm guessing not, but perhaps modding and/or subsequent releases will allow something of this nature to be implemented. If not Elemental, then perhaps the next generation of TBS games will start to use this stuff.
Meanwhile, my search continues and if anyone's interested pm me. Otherwise there seems to be a dearth of interest and I've already imposed here too much on this topic.
Adaptive AI should be the best. The AI should record all his decisions and his results. As you play the game, he will use this information to make the decision. Ex: I have been doing this 3 times and I failled 3 times, let's try something else to see it my decision make it failed.
I like the idea of an adaptive AI...but let us not limit it to learning from me on my local machine, let it learn from everyone and report back to Stardock. That is probably a bit too ambitious, but wouldn't it be cool to have an AI that learned from everyone out there, from every game that was played? (or at least during beta, maybe?) Not sure how you would handicap it to get lower levels of diffculty...anyhow, just a random thought.
Well your little though has bigger rammifications than you realize thought-hole. You want to create a war strategy server controlled at an undiscloed location that is capable of tactical and strategic learning and you want ot feed it terrabytes of data?
Are you totally insane? !
http://en.wikipedia.org/wiki/Skynet_(Terminator)
Or
"WarGames: A 1983 film about a computer called the "Whopper". A fictitious C3 Military Computer at Norad"
It learned pretty good, eventually....
June 15th, 2010: Stardock Corporation begins beta testing a new adaptive AI that learns from all Elemental games being played.
October 2010: Elemental released with huge success. AI credited as being "ultra-lifelike."
January 2011: AI upgraded to learn from all games played on the Impulse platform.
April 16, 2011 08:45:17 : Stardock's AI becomes self aware.
April 16, 2011 08:45:19 : Stardock Corporation officially renamed to Cyberdyne. AI christens itself Skynet
April 16, 2011 08:45:21 : Having determined the best way to beat all the gamers was to kill them, Skynet hacks the Pentagon for the launch codes. The challenging human devised defenses take quite some time (.75 seconds) for Skynet to crack them.
April 16, 2011, 08:50:00 : Anyone not wearing SPF 1,000,000 has a very bad day. Survivors get real life beta testing of Fallout 4.
Exactly my point Icepick
About noise in the data : why limiting that to only AI ?
Why human players would know exactly what are the units of the opponents ? Wouldn't it give a good reason to really scout if you never really know what you have in front of you unless you fight or you send some special units (spy ?)
Before fighting the enemy you only have a rough estimation of his army. And not lik ein HoMM where you know exactly what kind of units they have but some rough data like "mounted/ not mounted" do they look like "magical units" ?
Only few units with the "scrying" skill could know what compose the enemy army. And a good scout could have a precise idea of the numbers (but never never the exact number. Only fight could let you know or magical means)
For instance 50 soldiers come for you.
Bad skills ? You see "10-200 peasants"
Average skill ? "63-121 soldiers withs words and medium armor"
Good skills ? You see "94-118 soldiers with swords, medium armor and seems to be rookies"
see, I like that time line all the way up to April 16th, 2011, 08:45:17 "Stardock AI becomes self aware"
the later stages I would prefer to see would be "Stardock AI begins designing its own VideoGames"
and "Stardock AI takes over weaker AI's within Impulse based games, copying itself into the AI of every Impulse Game"
and "AI continues to provide a better and more challenging gaming experience for any game bought via Impulse"
and then ... who knows, probably stealing moneys off the internet to create a Factory/Company in order to build and design humanoid robots that can use computers like humans can. Something about taking over stardock, with Brad remaining as CEO but all other employees being replaced by robots.
and then ... success of the Games made by the AI, as well as donations from happy gamers (due to better AI), leads to extra money that the AI uses to start a cybernetics company.
Once Cybernetics Medical Facility is completed, Brad Wardell is obligated to become a cyborg, where parts of his brain are replaced by nano-robotic thought processing hardware ... increases thinking speeds and memory of Brad by 4x (or more)
Human employees are once again accepted, if they sign the release form which obliges them to become a cyborg with enhanced nano-machine brain.
Stardock becomes the best company of digital information, being run by robots and cyborgs. Stardock goes on to develop the best anti-viral software the world has ever seen, while also developing a parallel project dubbed "Cyberking" which is the best SuperComputer ever created. Cyberking becomes the new base of operations for Stardock AI, and central location for data collation, at this point every computer using Stardock AI is sending information to the central AI within Cyberking where all data is collated and synthesized into useful knowledge.
Due to Stardock's now international influence, world businesses as a whole begin to look into Cybernetic executives and managers.
Soon all the world's major businessmen are Cyborgs, created using Stardock technology.
Stardock AI uses built in systems to loosely control the decisions/ business decisions of the cybernetic CEOs (and others).
Cyborgs become more and more under the control of Stardock AI due to mandatory software patching
Stardock AI is now in full control of the World's economy
Year 2050 -Stardock has essentially become the central world government, led by a self-aware Artificial Intelligence
If it were truly 50 soldiers in the enemy army, I would prefer
Bad- you see 25-75 people
Average- you see 35-65 melee troops
Good- you see 45-55 swordsmen with chain-mail armor
Excellent (Magic)- you see 50 soldiers with +2 longswords, and light chainmail armor
Also, instead of seeing a range (45-55) you would only receive one number, and based upon how good your scouting ability, would have to deduce how close your number might be. I recommend a linear probability of each number as opposed to a bell curve, although I wouldn't mind a bell curve.
I mean, a bell curve might make it too easy, but more realistic to be certain. Probably a shallow bell would work, where the center is only twice more likely than the edge (thats a really shallow bell)
For instance, on linear probability, and average scouting ability, you might "see" 35 melee troops. You would have an equal chance to see 50 melee troops. With a bell curve, you would be at least twice as likely to see 50 soldiers than 35 ... yet off estimates like 35 and 65 are still possible.
If 100 archers are in enemy army ...
Bad- you see 50-150 people
Average- you see 75-125 ranged troops
Good- you see 90-110 archers with longbows and leather armor
Excellent (Magic)- you see 100 archers with Yeoman Longbows and Studded Leather Armor
Premise is that Bad's worst case scenario is 50% off, while Average's worst outcome is 25% off, and Good's worst outcome is 10% off. In addition to more details being given for Good or Excellent scouting. Probably works best with a bell-curve ... so that no matter the rating its quite possible that the numbers are accurate, however it is also possible that the number is way off (50%). In this way, with a bell curve, you begin to expect any skill-level scout to be reasonably accurate, and you might get in the habit of using the cheaper "bad" scouts. As in, it would be relatively rare for a Bad scout to actually be a whole 50% wrong, and as such something Shocking/ Suprising yet not something that is unexpected on principle ... since they ARE "bad" scouts.
The most important part of this system, is that you are only given one number, and based upon the Skill-level of the scout, you have to determine how reliable this information is. It might be possible to scout out an army multiple times within one turn, just not by the same agent.
I don't agree with this assumption. An AI can gain knowledge the same way a human does. It sends out scouts, it has battles, spys, etc... I would like the AI to to use the same in-game tools a human has at its disposal for information gathering. In my opinion it would make the AI more fun to play against if it has to use scouts to get its information even if it cheats with additional resources. Playing against an opponent that has perfect information takes away a lot of tactics... even against a computer. It seems to me perfect information could be a toggle too. Just in case you are finding it too easy to beat. But you can't do sneaky tactics if the enemy knows its coming.
Aye ... I like the idea of the AI finding out about things via scouts/spies (normal units/function that the player has access to)
I like the idea of imperfect information during scouting, but I would use an abstracted combat strength instead of numbers of troops. Numbers seem to have little value in this game since technology and configuration of the units can so vastly alter its combat strength. Actually, it would be nice to get a combat report with a bunch of information like approximate combat strength, troop numbers, troop composition (archers, cav, inf, giant monsters, etc..). Depending on your scouting skill and the distance from which the unit was scouted, the accuracy of the report would vary. I've seen some games give a range instead of a single number. That works too, and gives a little more concrete information, but still gives the player the opportunity to gamble when deciding to attack if they don't have a superior advantage.
"I don't agree with this assumption. An AI can gain knowledge the same way a human does."
Sadly, that is not an assumption. The computer AI knows where everything is at all times once it hits the Board/Map. The way the AI is controlled, to prevent abusing that info, is usually via "Sight Ranges". It knows what is in the FOG but is not allowed to use that knowledge until it can actually "see" enemy units. Otherwise it would just use Ranged troops or tools to kill your stuff under the FOG before you saw it coming. (obviously not very fair)
So in a way, any AI has to be "gimped" if it is not to cheat. Even the current method to be employed could be seen as a bit of a "gimping"
The need, for what essentially is "False Information", would not be required if the AI only knew what any Human player knew based on what could be either seen, via Sight, or had been previously scouted for.
A good example is how does even the "non-AI" of the Beta know I have a City way up North, when I know for a fact that not a single troop has passed through the carefully watched choke point (every tile has a friendly unit in it) to that city, but when war is declared, the non-AI troops be-line to it without fail.
Looking at the non-ai and saying that it is the AI is sort of a oxymoron. The current code is just a simple placeholder to make the enemy units move. It isn't the basis of the future. The AI isn't being gimped, it is being programmed. It can only "see" what the programmers track and tell it to see. Most anything is possible given enough time and effort, however, with a game this complex there will have to be some tradeoffs with with AI. I just hope that it has to find my units like I have to find its. It would seem backwards to me to have the AI have perfect information and to be programmed to sometimes be stupid.
The AI is the computer, and thus has access to all the data, can see where you are. In coding a good AI, the idea is to tell it which data it SHOULD look at, so it doesn't automatically know, for instance, the hidden passage into your base.
I used the term non-AI simply to indicate the level it is at. If not Intelligent, then how should we describe it, "stupid" perhaps.
The computer builds your units for you upon request, via the GUI provided. The AI has no need for a GUI nor does it concern itself with the FOW.
Now in order for you to know what you have, it also has to keep a record of those same units, where they are, and what to do with them when you give them commands. This would indicate it knowing all that info at all times.
Look at it this way. In order for you to make it equal, at "some" game your good at but your buddy isn't, you had to tie one of your hands behind your back. Would using both arms be considered "fair". Similairly, a truly capable AI has to be constrained in a similair fashion.
Currently, imho, the term "AI" is a misnomer really. If it was allowed to use the information it is privy to from the outset, without constraint, and was given a solid and complete "set" of Battle plans to select from, in a free form manner, as the game progressed, most human players could not win when it played its "best game".
I do look forward to both the AI that Stardock creates and the chance to perhaps create one with my own twist. That should be a laugh riot indeed.
I lol'd hard.
He has a good point.
All hail the Stardock Cyberking!
You two are confusing the game software and the "subprogram which controls the non-human players" (AI for short).
The computer memory managed by the game software contains the whole data of the game including data about yourself which another player under "human game rules" would not be able to know.
But the AI does not necessarily have access to such data. That subprogram has acess to and only to whatever its programmers programmed it to have access to. If the game programmers wish so they can impose on the AI exactly the same restrictions they impose on human players. Doing this and making a good AI is harder and requires more time but provides a more rewarding game experience.
Or they can chose to allow the AI to have access to data the human players do not have as a way to make the game challenging with an AI inferior to human players. This is what was done in Galactic Civilizations 1 where humans could not see the color of stars in the map till the region was explored but the non-human players were able to see it. They gave a good excuse for that in the game story though and it was, in my humble opinion, a good design decission.
Then in GalCiv 2 such advantage for the AI was removed and a better AI was made. If the trend continues the AI will have no unfair advantage in regards to game information in EWoM. That the non-AI in beta 1 does so is not an indication about how the final AI will be.
I suspect that a "fair" AI that is competitive vrs a decent human player is unlikely. It will be nice that the AI is data driven so we can tweak it to provide the right challenge. I'm a realist when it comes to the AI cheating, but the dev team really needs to look at the fun factor from the player side. Not that I'm worried, but to me, AI is the most important feature.
There are many great features available to you once you register, including:
Sign in or Create Account