Sneak peek at the AI changes

I didn’t realize how much I missed working on AI until I started working on it again. So far I think I have been able to make a vast improvement in how the AI plays. I want to thank everyone that posted feedback, it was very helpful. I will have to check the list again, but I am fairly certain I have fixed or at least improved upon all of the relevant issues. The change list for the AI so far is longer than any version of the AI I released for SupCom 1 or FA. Before I post highlights there are some things you need to know.

First, you need to realize that some of these fixes may not make it in right away, if at all. They still have to be tested to make sure I am not epically breaking anything. Second, I still do not know when these fixes are going to be patched it, so don’t get upset if they aren’t in the next patch, or even the one after that. There are a lot of fixes spanning many files, so in the interest of keeping patch sizes down it may be delayed until we can include it without killing everyone’s bandwidth.

Probably the biggest bug was the fact that threat conditions were not being used properly. Threat conditions are what we use to tell the AI to do something in reaction to a threat, such as building AA when an enemy has air units. Not only is this fixed, but the AI is using the threat value of its currently targeted enemy to determine how big of a platoon to send and how many experimentals it needs to have built before sending them out.

The AI also takes into account build restrictions when choosing which archetype to use. It also recognizes when it has all research, so it won’t waste mass on research stations when it does not have to. Also, the AI should no longer get stuck if you rush it and destroy something while it was in the middle of its starting build. If you restrict a unit type in the game the AI now acts like that unit doesn’t even exist in the game. Don’t want nukes in the game? The AI won’t even have the option of giving one of its engineers the order to build one.

Most of Thursday, Friday, and Monday the 22nd was spent fixing little bugs like the above. Tuesday and Wednesday were spent balancing and getting the AI focused. The biggest challenge was the AI’s economy.

The AI uses a bucket system for its economy. When the AI gets resources it puts a set percentage in each of its buckets (defense, expansion, experimentals, land units, etc) and it puts any excess resources in a slush bucket. When the AI wants to build something, it checks the appropriate bucket to see if the resources are available. For immediate items (like emergency shields or economy related stuff) we tell the AI to use from all the buckets. The problem with that is the AI ends up taking from the same buckets over and over. Later in the game, when expansion is harder, the expansion buckets ends up getting filled and never used, so the AI ends up in a situation where it has a lot of mass, but can’t build.

My solution was to make the AI take resources from the slush bucket first when taking from all buckets. Then, I sort the buckets from fullest to emptiest and take an amount from each bucket based on how full it is until we have enough or run out of buckets. If the first pass doesn’t get enough we re-sort and take all the resources from each bucket until we have enough. This way, full buckets that aren’t being used much are the first to get resources taken away and the AI has a much smoother economy.

I also worked to get the AI to focus a lot more. The AI would constantly send units, that were doing hefty amounts of damage to an enemy base, across the map to kill and few units that had the audacity to get near of its expansion bases. It also didn’t focus its attacks on its targeted enemy very well either. It took a lot of trial and error, but I think I have it dialed in a lot better.

Another nice upgrade is that the AI will now use the Mass Convertor. Prior to this the AI would never build one. Now, the AI will build one (it only needs one) or, in the case of Cybran, use the ability of one of its power generators.

I am still working out the cheating situation. Some people complain that the Hard AI cheats too much and the Cheating AI cheats way too much. Currently, I have asked a few people in the office of different skill levels to try out the new changes and see what they think.

Now, as with the last post, I have a request. I would like some ideas on research paths. I plan on going over them again and trying to optimize them and wanted ideas on what paths players use. I don’t need an exact path, per se, because I have a function I use in the AI that finds the cheapest path to get to a particular research. What I need is what research item you go for first, second, third, etc. If you are going air, do you get gunships first? Shields? Or, do you go for the experimentals? Let me know.

For those of you who want a tl;dr list of the AI fixes, here you go. Bear in mind, this list is not exhaustive, so don’t get upset if you pet fix is not listed. This is also not a guarantee that they will show up in any patch, let alone a patch that is released soon.

  • Fixed a bug where threat build conditions were not being used.
  • The AI will hold back units until it thinks it has enough to make a push.
  • Fixed an issue where the AI would constantly pull units back to attack an expansion base instead of pushing forward.
  • Added AI response to make a land AI get land unit AA upgrades if the enemy has air units.
  • The AI will no longer get stuck in its startup build sequence if rushed or if there are build restrictions in place.
  • The AI will no longer give every structure blip AA and Land threat; instead it will wait until it has seen the unit first.
  • The AI will no longer give blips on the water Naval threat, it will wait until it sees an actual ship.
  • If Research is disabled the AI will not build research facilities.
  • If a unit type is restricted the AI will act as though the unit does not exist in the game.
  • Platoons will try to only attack areas where they think they can do enough damage before dying.
  • The AI should no longer attempt to send attack platoons to unpathable areas.
  • The AI will choose an appropriate archetype based on unit restrictions.
  • Re-balanced the way the AI chooses an archetype.
  • The AI will react to enemy TML, artillery, or Experimentals by building more shields and placing them closer together.
  • Enemy shields are now given AntiLand and AntiAir threat.
  • AI will build and use Mass Convertors.
  • If the closest enemy to the AI is a lot weaker than the other enemies the AI will focus on the weak enemy.
  • You can now select which AI type you would like to play against from the dropdown in the game lobby (random is still an option).
  • AI will build factory shield upgrades more often, not just when the enemy has air.
  • Factory upgrades now have a threat value.
  • AI will not build research stations if it already has everything researched.
  • AI will now group units based on their target enemy's threat.
  • AI will now group experimentals based on their target enemy's threat. 
The last few changes are in for this round, unless something pops up in testing.
  • The AI is now aware of the victory condition and will focus attacks on the ACU more in assassination mode.
  • When an AI unit dies it will add threat to the instigator's location to warn other units.
  • AI will respond when an enemy turtles.
  • AI will now recognize when it is being attacked by nukes or artillery and respond.

      I'm back, baby!

      I have been pulled off my current project, at least for now, to work on SupCom 2 again. Yay! I will be working on fixing the bugs in the AI (found a huge one today) and generally improving the way the AI plays. For the most part, the AI does fairly well. Once I get the bugs ironed out and tweak some things you should see a pretty decent improvement. Unfortunately, I do not know when these fixes will actually make it into a patch, but I hope it is soon. We need to test these changes as much as possible before releasing them and finding out later that we made things worse.

      The other great thing about being back on SupCom 2 is I get to be brought up to speed on the other things we have planned. The next few patches are going to be cool. Some nice changes, some cool new features, and of course, ranked 1v1. Of course, this will give me more to blog about as well. I also got to sit down with Chris and go over some other things I would like to see changed. The outlook for future patches looks good.

      So far, I think I have found the main cause of the complaint about the AI not reacting to things the enemy does, as well as the AI getting stuck when you rush it early. I also have done some preliminary balance changes, and also changed some weights for how the AI chooses which archetype get used. This is just a small part of the list I have been given to work through. Any of you readers have any other complaints about the AI? Feel free to reply and let me know what you would like to see. I know I have my own list, but I want to hear from you. Please be as detailed as possible.

      The next few weeks should be exciting.

      ( btw, Bender quote ftw :) )

      Video blog #5 is up

      Video blog #5 is up at If you haven't been following the vblogs, now is the time to start. This time around Chris interviews Gautam Vasudevan (Lead Engineer - Kings and Castles) and barges in on an engineering meeting and interviews Chad Queen (VP of Engineering). Of course, there is also some craziness, this time involving trees.

      Supreme Commander 2 has been out for about a week and half, and, at last count, it has been patched twice already, which is awesome. is even getting ready to host its second tournament. It is nice to finally get to see the game out in the wild and being enjoyed. Now, if I could just get an opportunity to get in there and tweak the AI a bit...

      I think I have about 3 more weeks on my current project (as I said, it was short term). I am looking forward to getting to take a crack at Kings and Castles and being on a project I can actually talk about. Hopefully, I get to dig into the AI more. On Supreme Commander 2 I only got to work on the AI for about a month. This time around I am hoping to work on the AI from start to finish. The base of the Supreme Commander 2 AI could definitely be used for Kings and Castles, which would give me more time to add in other cool and interesting ideas that pop into my head.

      GDC 2010 ends tomorrow. Wish I could have made it this year, but oh well. I am definitely going to try to go next year.