How the AI got to where it is now

I have been getting a lot of questions about what I did to the Supreme Commander 2 AI and why. I certainly have no trouble talking about the AI (ask my family or anyone I work with) so hopefully I can shed some light on what changed and maybe even what didn't make it...yet.

Back in March I got received a list of bugs that were reported about the AI and was asked to give a time estimate on how long I thought it would take to fix them all. I was also asked to provide a list of things I would personally like to see fixed. It was a fairly long list with some of the issues being very broad ( like: "AI does not adapt to player strategy.") which I was very happy to see. Broad bugs can mean broad solutions. My reply was that I would need a month to go through and fix all of the issues. Now, I believe in the Scotty theory. When your boss asks you how long something will take, always add extra to your estimate.

The day I was supposed to transition to working on the Supreme Commander 2 AI I was pulled aside by Chad (SupCom 2 engineering lead at the time) and he said the most beautiful words to me. He said I would have autonomy with regards to the AI. I don't remember if I giggled after he said that, but it would not surprise me if I had. Basically, I could do whatever I wanted with the AI as long as the bugs got fixed, there was an overall improvement in the AI, and I didn't kill perf or introduce any more bugs.

Starting out, a lot of my time was spent fixing the various bugs. There were issues with the AI getting stuck in its starting build order and then not doing anything else. There was a bug that was preventing the threat build conditions from working at all (threat build conditions allow the AI to change behavior based on enemy threat). The AI had trouble with exclusions, factory upgrades, build queues, even just picking somewhere to attack. I probably spent a good solid week just working on some of the simpler bugs.

Some of the bugs, however, were not so simple. You would think getting the AI to build an anti-nuke when it gets nuked would be simple, but you would be wrong. I had to write support for an OnDamaged event for the Event Manager (AI manager that controls what happens when certain events get triggered, such as when experimental research is obtained) that would get checked whenever an AI controlled unit took damage. This was something I could only dream of in SC/FA. This is the kind of change I really like.

Reaction. Such a simple concept, but something that I think is underutilized by RTS AI. Simply making an AI react to things that the player does adds so much more immersion, especially if you do it right. Making the AI build shields when it sees an artillery being built or starts taking artillery fire. Making the AI build AA when it sees a lot of enemy air units. Making the AI send bigger and bigger waves as the game progresses. I am a huge fan of making an AI react, and react intelligently and I think some of the biggest gains in the AI came from this concept.

The other system that gave the AI huge gains was the economy system. I discussed one of the changes in a previous blog post (the AI constantly taking from the same resource bucket over and over). There are two more changes that had significant impact. One change affects the AI late game. I noticed that the AI would end up having a huge amount of resources in its slush bucket, but was unable to build because its other buckets were empty. Now, every so often, the AI will check to see if it has more resources in its slush bucket than it has missing from its other buckets. If so, it will pull those resources from slush and distribute them into the other buckets. Now when you watch the AIs resource buckets late game they are almost always full.

The other big econ change was to the reservation system. The reservation system is used by engineers to reserve resources for build orders. This prevents the situation where an engineer is given a build order, but the resources get used before the engineer can get into position. The problem is that these reservations were not always being removed when the engineer died. To prevent that, the resource manager now goes over all of its reservations every so often to make sure the unit that owns the reservation is still alive. So, the AI no longer ends up in the late game with 3000 mass worth of reservations for dead units.

I think my favorite change, however, is the recent AI Overlord system. Playing against teamed AIs and seeing a massive group of units comprised of units from more than one AI just brings a smile to my face. This is another one of those changes I could only dream of in SC/FA and I am so glad it is finally here. The AI Overlord system is a manager that controls how the AI acts as a team. It ensures that all AIs on a team are attacking the same target, it allows the team members to group units together, it provides a system for a team member to call for help, and also has a system for team members to warn other team members when one of their OnDamaged events gets fired off (so if you start hitting one AI with artillery, the others on the team will know it and build shields in response).

Of course, people want to know what things got cut from the AI. What did I want to do, but was not able. Honestly, that is a difficult question to answer. I never believe an AI is done, because there is always something else my twisted mind will come up with. I keep a word document scratch pad of sorts that I can access from home and the office. Whenever I get an idea, it goes on the scratch pad. There quite a few ideas on there both from before and after the latest AI updates went out. Anything that does not make it into Supreme Commander 2 you will surely find in Kings and Castles. Hopefully Square Enix will be willing to put some more time into the AI. Who knows what I could do with another month.

15 comments:

Veteran Sergeant Centurius said... / May 17, 2010 at 10:27 PM  

Are you an all powerful future space man/god/king/potato?

EdWood said... / May 18, 2010 at 12:31 PM  

Thx Sorian,

very interesting and your improved AI is really fun to play against now. Rock on. :)

Ed

olivier said... / May 18, 2010 at 12:49 PM  

thanks for taking time to share all this with us Sorian. I have a few questions : Is AI system in K&C similar to Supcom 2 AI system ? If Yes why developping a new feature for K&C would take so long to be added to Supcom 2 ? Shouldn't GPG consider AI as a constantly evolving middleware that could benefit to a previous title ? If it's all about lowering the cost of making a game, then as for the moho engine, there should be an AI engine. Do you think a learning AI is possible ? (expert systems or neuronal Network ?). I remember MASA did an attempt in Conflict Zone a few years ago, but never retried. As far as you is there such an existing middleware ? I think that if GPG considers Solo campaign and Multi against AI to be a key factor to a game success, then much more efforts/money should be invest for this.

Sorian said... / May 18, 2010 at 1:37 PM  

@oliver: The SupCom 2 AI uses Neural Networks as a fight or flight mechanic for AI controlled platoons. I plan on trying to expand this for K&C.

The AI portion of the game engine for K&C is going be basically the same as SupCom 2. There will be changes made, of course. All of the platoon specific behaviors will probably be dumped. Not sure what else will have to change yet.

A lot of the recent AI updates (like the AI Overlord) came about because I was testing things for K&C by putting the changes into a local build of SupCom 2. It was very successful and cool so I was able to actually put that into the mainline version of SupCom 2.

If Square approves more work, I will be happy to oblige. I have lots of other ideas I would like to implement, but I am assigned to work on the K&C AI yet (not much to be done yet), so I can't justify fiddling in the SupCom 2 AI much.

olivier said... / May 18, 2010 at 2:02 PM  

thx for your answers Sorian ;-) it's pretty cool to get this "behind the scene" picture. Hope to see you soon in K&C video blogs !

Brian said... / May 18, 2010 at 7:58 PM  

It just makes me sad to see so many things moved into code that can't be modded. While I understand the reasons for it, I just wish there was still some way to get my hands around some of it and change it.

Hopefully something can be done with KnC to give the best of both worlds. Performance of everything engine side, but some way to mod it

Derek said... / May 19, 2010 at 10:59 PM  

Hello,

I"m a huge fan of A.I. myself, so I must ask a question,
with supreme commander 2, even against 3 HARD a.i.'s, you can always easily defeat them by just hunkering down, and building long range artillery, especially if you create a bottleneck, A.I never wins, even with the new overlord feature, they all attack the bottleneck and always die, you see this all the time online, so ...can this be fixed?

Collin said... / May 21, 2010 at 7:17 PM  

The new AI code is awesome! I've just played several comp-stomps where I got stomped...I guess 4 on 1 isn't really fair to me lol.

Anyways...playing these long-games made me remember one of the big reasons I stopped playing this game: no saving during skirmish play. Would it really be that hard to have a save-feature in the single-player non-campaign game? It isn't 1995...my hard drive isn't going to fill up from rampant saves!
I know you aren't the one to bitch to with this, but I feel as if there is no authority presence on the forums.
Cheers,
Collin

Sorian said... / May 21, 2010 at 8:44 PM  

Setting up saves in skirmish is a lot more complicated and a lot more work than people realize. I think steveb mentioned on the forums that it was on our list of things we would like to do, so hopefully we get to do it. It would just take a lot of time, effort, and testing.

Collin said... / May 22, 2010 at 12:45 PM  

Well I hope it gets in. It is the feature I miss most from the first game.
Thanks, though.
Cheers,
Collin

EdWood said... / May 28, 2010 at 10:43 PM  

Congrats for your first appearance on Kings and Castles Videoblog. Dude, that was overdue. :)

karatefan said... / May 28, 2010 at 11:09 PM  

I want that Teleporter.
How much do you want for it?

olivier said... / May 29, 2010 at 6:03 AM  

At last ! I thought we'd never see you on this crazy Video Blog. Congrats Sorian !

Veteran Sergeant Centurius said... / May 29, 2010 at 1:40 PM  

All Hail Sorian, the king of AI!!! We have finally seen the king in his natural environment! ALL HAIL SORIAN!!!!

Tormod said... / June 1, 2010 at 1:32 PM  

Yeah, gratz on the videoblog! =D

Post a Comment