RTS AI workbench

Started by
15 comments, last by LeventeZs 12 years, 9 months ago
I'm working on an RTS workbench tool, that is: minimalist graphics, 2D world, units have hitpoints, attack points, range, speed (these are the default attributes). The intended use is to extend the basic unit class, and override the behaviours/game rules you don't like (default rules mimic a run of the mill RTS). So you can concentrate on experimenting both with unit level ai and player level ai.

It's all in really infant phase (0.1), there's no documentation besides some Javadoc (hands-on no getting started guide). But I have some code that runs, and it might give some idea where I'm heading.

I also plan to build in some tools for evolutionary algorithms (yeah, I know, sounds ambitious), so you write a player's code, define a sequence of evolutionary attributes and their range, and the in some points in your Player code you read those attributes. The framework will "breed" the player and mutate (e.g. simulated annealing), and cull the population (different specimens of "Player strategies" fighting against each other). I know, there are already projects like this out there, but they ...
1, have weird rules and not resemble regular RTS
2, use C/C++ (I think that's too level language to progam an AI in)
3, are tied to proprietary game (e.g. Starcraft)
4, only provide a server and not an IDE like environment where you experiment, aggregate and visualize data

I'd like to hear suggestions/feature requests from you, or just comforting cheering :)

The project is BSD licensed, however I'm not recruiting contributors, so if you like what you find feel free to fork. I'd like to get my planned features and documentation get done till October/November. (My schedule has been quite hectic in the last 1.5 months).

The project is hosted on Sourceforge and is humbly called Infinite Wisdom.
Advertisement

2, use C/C++ (I think that's too level language to progam an AI in)


what do you mean ?

Never say Never, Because Never comes too soon. - ryan20fun

Disclaimer: Each post of mine is intended as an attempt of helping and/or bringing some meaningfull insight to the topic at hand. Due to my nature, my good intentions will not always be plainly visible. I apologise in advance and assure you I mean no harm and do not intend to insult anyone.

I wouldn't write AI in Java unless I had a gun to my head.

Of course, I wouldn't write anything in Java without similar extenuating circumstances, so take that for what it's worth.


The idea has potential, but has a few critical shortfalls from my perspective:
  • Java. Nobody writes high-end RTS games in Java. You need at the very least to build a scripting framework that can drop into a C/C++ engine if you want anyone to take this seriously.

  • Too much emphasis on evolutionary algorithms. This might be a fun diversionary project for some research, but it isn't how real AI is developed. Real AI in the RTS space is generally heavily focused on things like utility maximization and build order scripting. Some of the more complex issues are things like path planning for masses of units (think Zerglings in Starcraft II) and those aren't going to be solved by GAs any time soon.

  • You don't seem to account for the fact that every RTS is going to have a very different set of rules. What made Total Annihilation a great game was vastly different from what made Dune 2 a great game, or Warcraft, or Command and Conquer. Those rules and design decisions shape the AI far more than code ever will. What you really need here is more like an end-to-end toolkit for designing and implementing an RTS; ability to define and implement rule sets for resources, unit and building production, movement controls (think air/sea/land), and so on. There's also a horde of small details to consider, like units that can dock to each other/inside each other (transports), how buildings and static defenses might affect gameplay, units that can transform between various states (e.g. siege tanks), and so on.


I like the concept in principle, so don't take this as anything more than constructive criticism; in fact I think it'd be cool to have a prototyping tool for RTS games that worked very similarly to what you seem to be envisioning. But to make it really kick-ass, I'd suggest shifting focus a bit: build a scripting or other high-level data driven system that lets a designer prototype an entire game from start to finish (sans graphics, sound effects, whatnot) and see how it actually plays. Build in rich support for AI scripts written in, say, Python or Lua, and provide a set of hooks for built-in stuff like a pathfinder and so on.

What you could end up with is a great tool for designers of RTS games to sit down and hammer out all the rules for their game first and foremost, then have AI engineers rough out the gameplay logic for the computer players, and then ideally just copy/paste their scripts into a C/C++ framework that integrates into custom rendering engines and so forth. You could bootstrap an entire game like StarCraft in a matter of days with such a toolkit, and I think it would be truly cool to have something like that available.

Do it right, and you might even get guys in the AAA industry space using your tool for prototyping.

Massive bonus points for including a rudimentary network code implementation that can be used for playtesting PvP combat...

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]


... Build in rich support for AI scripts written in, say, Python or Lua, and provide a set of hooks for built-in stuff like a pathfinder and so on. ...

What you could end up with is a great tool for designers of RTS games to sit down and hammer out all the rules for their game first and foremost, then have AI engineers rough out the gameplay logic for the computer players, and then ideally just copy/paste their scripts into a C/C++ framework that integrates into custom rendering engines and so forth. You could bootstrap an entire game like StarCraft in a matter of days with such a toolkit, and I think it would be truly cool to have something like that available.

... Massive bonus points for including a rudimentary network code implementation that can be used for playtesting PvP combat...


Last two weeks I've been working on an RTS game written in C# using Xna. It's a slightly simplified Age of Empires clone right now with almost no content, but it does feature about 75% of all low level game elements of a such game. I was about to implement the (high-level) AI interface today actually, as the game currently features only PvP multiplayer battles for 2-4 players. Since I'm using .NET, AI modules can potentially be written in any .NET language such as VB.NET or JScript, but my initial release will feature just C# and IronPython support.

While the game is an AoE clone, the engine was designed to be extremely flexible in most areas. I could probably create a 'Civilization' that would play almost like a StarCraft race already using Python scripted civilizations. I could drop in any Xna-compatible rendering engine as long as it supports rendering to texture and/or rendering to a specific viewport.

My goal is however different from this project in that I'm trying to create a fun game.

  • Too much emphasis on evolutionary algorithms. This might be a fun diversionary project for some research, but it isn't how real AI is developed. Real AI in the RTS space is generally heavily focused on things like utility maximization and build order scripting. Some of the more complex issues are things like path planning for masses of units (think Zerglings in Starcraft II) and those aren't going to be solved by GAs any time soon.

The idea is to spice up scripted AIs with GA. (The GA framework finetunes the "constants" in your scripts.)
Also, don't confuse Genetic Algorithms with Genetic Programming. I don't intend to build in support for Genetic Programming.

  • You don't seem to account for the fact that every RTS is going to have a very different set of rules. What made Total Annihilation a great game was vastly different from what made Dune 2 a great game, or Warcraft, or Command and Conquer. Those rules and design decisions shape the AI far more than code ever will.
[/quote]
As I said, the gamerules are flexible. The default rules are what generic RTS-es does (HP, shield, splash damage), but should be easy to override. Also you're supposed to write the rules in Java (the horror) by extending/reimplementing the gameplay class.


I like the concept in principle, so don't take this as anything more than constructive criticism; in fact I think it'd be cool to have a prototyping tool for RTS games that worked very similarly to what you seem to be envisioning. But to make it really kick-ass, I'd suggest shifting focus a bit: build a scripting or other high-level data driven system that lets a designer prototype an entire game from start to finish (sans graphics, sound effects, whatnot) and see how it actually plays. Build in rich support for AI scripts written in, say, Python or Lua, and provide a set of hooks for built-in stuff like a pathfinder and so on.
[/quote]
I'm already working on a grid based path finding utility that integrates smoothly with the rest of the framework.

What you could end up with is a great tool for designers of RTS games to sit down and hammer out all the rules for their game first and foremost, then have AI engineers rough out the gameplay logic for the computer players, and then ideally just copy/paste their scripts into a C/C++ framework that integrates into custom rendering engines and so forth. You could bootstrap an entire game like StarCraft in a matter of days with such a toolkit, and I think it would be truly cool to have something like that available.
[/quote]
That's the vision. However on the short term (next 1-2 years) I plan to concentrate on the gameplay features, the shiny stuff should come later.
Even if it will be a prototyping tool/testbead for new ideas, it could be immensly helpful. As I heard, AI is bolted on in a rush on the later phases of developement in a lot of games. This tool would allow to test AI ideas in earlier phases.

Massive bonus points for including a rudimentary network code implementation that can be used for playtesting PvP combat...
[/quote]
The idea is to be able to train the GAs without networking overhead, and then running them in networked tournaments, with non-cheatable server (no gameplay rules deferred to clients).
Also, if you have many machines, you should be able to train them on the network too.
But at the moment I concentrate on local stuff, but design interfaces with networking in mind. (Not an easy task.)

Anyway, this started as "a fun diversionary project for some research", so I will content even if it remains that. If I can gain some new insights as an RTS player, it was worth it.
The GA part makes me wince as well.

blink.gif

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

Really? I'm working on an RTS AI as well, using potential fields and behavior trees. Both of these end up with lots of tunable "weights". For example, when a force encounters an enemy, they can choose to attack, defend, retreat, or bypass. These are each behaviors chosen by a weighted random selector, where each weight is a sum of a weighted value for the enemy's strength, a weighted value for friendly strength, a weighted value for how favorable the terrain is, etc. When a unit is moving, its potential field utilizes many different factors as well (how much to prefer cover vs speed, for example).

A GA seems like an excellent candidate to handle this sort of combinatorial explosion. You have a multitude of different variables, with no precise right answer. As long as you can measure the results in order to perform selection, shouldn't a GA be able to work here? I'm hand-tuning everything now, but I was hoping to be able to serialize these behavior trees into chromosomes and run them through a GA while the AI plays millions of games against itself.
Anthony Umfer
If you build your tunable weights properly -- especially by making them hierarchical and neatly defined -- then it isn't that daunting of a challenge to tune them by hand to achieve the behavior you want.

(Sorry for the brevity... I'm cruising E3 this week.)

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"


Really? I'm working on an RTS AI as well, using potential fields and behavior trees.


I already have some nice classes to visualise custom potential fields. (Overlays)
Yeah, I see you get the idea. I'm happy to find some like minded fellow, not just C++ snobs :)



You might want to ponder the "C++ snobs" bit a little more. I was a VB guy and went out of my way to learn C++ specifically because that's what the industry used. Whether I liked it or not, nothing I wrote in VB was going to be worth a crap to anyone else. If I was going to actually work in the biz, then I needed to break away from what I was comfortable and play along with the rest of the kids.

When in Rome...

Dave Mark - President and Lead Designer of Intrinsic Algorithm LLC
Professional consultant on game AI, mathematical modeling, simulation modeling
Co-founder and 10 year advisor of the GDC AI Summit
Author of the book, Behavioral Mathematics for Game AI
Blogs I write:
IA News - What's happening at IA | IA on AI - AI news and notes | Post-Play'em - Observations on AI of games I play

"Reducing the world to mathematical equations!"

This topic is closed to new replies.

Advertisement