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.

Patch 1.14 is live

Patch 1.14 is live and in the wild. The patch debuts the AI Team Manager, a system that allows the AI to work together when on the same team. I am very excited to see this finally out in retail. I was able to do things that I could only dream of doing in SC/FA, like having the AIs group units from multiple AIs into one platoon to be controlled by one AI. They also pass the word along if they start taking Nuke or Artillery damage. I hope this makes the AI more fun to play against.

Patch notes for 1.14: http://store.steampowered.com/news/?feed=steam_updates&appids=40100

I spent a couple of days last week working in VB Script, something I haven't touched since High School, and hope to not have to do again for a while. It is kind of rewarding getting some features into an internal tool that have been wanted for quite a while, especially when they said it couldn't be done. I also had to work with 3dsMax scripts for the first time. It is always interesting trying to fix bugs in a language you have never used before, but it had to get done. I needed the exporters to work for....wait, I can't talk about that yet. Ha ha.

I have also spent a good chunk of this week working on Demigod fixes. Apparently Stardock has sent us a list of bugs they would like to see fixed, and I am happy to oblige. It gives me a reason to kick some AI butt with Demon Assassin on work hours. I did manage to fix a bug that has been bothering me since the last patch, which is nice. As per usual, I don't have a time frame. I am hoping a build gets put together tomorrow and then it will have to go through Stardock QA.