Emergent AI In an Indie RTS Game
x4000 writes "My recent RTS game uses a new style of AI that hybridizes rules-based AI with emergent AI logic. As a disclaimer, I'm really not an AI programmer at all — my background is in databases, financial modeling, etc. But it just so happens that database experience, which often involved distilling data points from multiple sources and then combining them into suggested decisions for executives, also makes a great foundation for certain styles of AI. The approach I came up with leans heavily on my database background, and what concepts I am familiar with from reading a bit about AI theory (emergent behavior, fuzzy logic, etc). The results are startlingly good. Total development time on the AI was less than 3 months, and its use of tactics is some of the best in the RTS genre. I'm very open to talking about anything and everything to do with the design I used, as I think it's a viable new approach to AI to explore in games, and I'd like to see other developers potentially carry it even further."
Summary reads like a marketing blurb but the actual article is slightly more interesting. The basic idea is that in an RTS game, the AI is at a unit level rather than an 'almighty all-seeing controller'. It is a fairly interesting idea and does sound sort of different way of thinking about computer RTS opponents. Weather or not this actually makes for a fun game or a good idea remains to be seen, but at least there is something (dare I say) slightly innovative about this.
I'll ignore the shameless plug.
Ever since I wrote my first connect 4 game in the 80s - and was totally thrashed by it, I never beat it - its been clear to me that the trick is to degrade a computer player in most circumstances to the level that it appears to have human flaws and play in a more human fashion.
Of course this logic only goes so far and some games require a search space so vast or a completely different programming model that even now a computer cannot beat a competent real human (Go is an excellent example of this).
The point is that it is easy to program a computer to win, the hard part is to program is lose convincingly.
I quote "the graphics have been made available under an open license in April 2007" http://en.wikipedia.org/wiki/Tyrian_(computer_game) so how are they stolen?
I have yet to see anything that beats Master of Orion's AI
But to be fair I've played very few strategy games in the last 10 years, so shoot me down if I'm talking out my arse :)
In MOO the AI would recognise your tactics, and make moves specifically to counter them. You couldn't keep using a winning strategy.
A good tactic early in the game was to build a large number (thousands) of tiny cheap ships loaded to the brim with MIRV missiles which would overwhelm the defences of the far larger, well equipped and expensive enemy ships.
The AI would then counter by building a large number of small defensive ships, and equipping ships with ECM units, displacement devices etc which made missiles ineffective.
Man that game was good. Perfect blend of simple gameplay and deep strategy. I've never played anything else as good, modern 4x space games all seem to be about micromanagement.
The game isn't online, it's client-server between players. The "host" is just another player.
And we give credit to Daniel Cook in exactly the manner he requests. Really awesome of him to provide that sort of art for free, indie games are the better for it.
I'm not going to release the game for free, given that if I'm to be able to continue to pursue game development it can't continue to be in my hobby time forever. For similar reasons, I'm not going to release the entire code as open source. However, I've already open-sourced a lot of smaller things from my code (force feedback code from my other game, fixed-int math from this game, etc). Also, I've now added a second part to the article which has some partial AI code from the game, and people are free to use the ideas there and build off of them as much as they want. I don't want people to make AI War clones, but rather to think about the ideas that I am presenting and implement them in their own way. The AI War code is not the only way to approach this general design philosophy, not by a long shot. Here's part 2 of the article, with the added code and such: Designing Emergent AI, Part 2: Queries and Code
This is a really interesting post, and some of it goes a little bit over my head. Like I've said, I'm a database programmer, not an AI programmer. I might experiment with things like neural networks and such in the future, but right now the AI is doing as well as I could possibly hope for. That was a big part of the point of my article: using the fancier techniques is not even always needed for something like an RTS game, because you can get surprisingly good results with comparably little code.
I'm sure I will experiment around with this more in the future, but I bet you somebody else builds on my approach and does something more impressive before I even can. Anyway, future articles in my aI series will go more in-depth and will also include relevant code snippets to help illustrate my points. Feel free to use and abuse them, and expand away.
The second article is now up, to appease those hungry for some source code and a bit more of an in-depth discussion on a couple of sub-topics: Designing Emergent AI, Part 2: Queries and Code.
Thanks for the added explanation -- and I'm glad you found the second article more interesting. It has only one audience (programmers), which makes it easier to write. The other perhaps has too many target audiences. Switching up the relative weights of the preferences, and having the AI retain information and learn over time, is quite interesting. Beyond the scope of what I can probably accomplish in this game simply because of data size issues and such in a networked game (unless the AI had a permanent local database, and each computer's version of the game would thus have different intelligence). But very interesting, and I suspect I will probably try something more advanced along those lines in the future.