Since so many of you have requested more info on how the neural nets in Supreme Commander 2 work I have decided to make another blog entry to go into the neural nets in more detail. Actually, I am a bit surprised I haven't made a blog entry about them already.
Supreme Commander 2 contains 4 neural networks, each of them consisting of 3 layers of neurons (input, hidden, and output) and learn via backpropagation. There is a neural network for Land, Naval, Fighter, and Bomber/Gunship. The neural networks are used for AI platoon fight or flight mechanics which are used by the bulk of the AIs combat platoons.
When a platoon is formed it contacts the AI's strategic manager and requests a place to attack. The strategic manager looks at the map and chooses a place to attack based on a risk versus reward ratio. It also checks for pathability. Once it has chosen a spot it generates a path using good old A* and returns the path to the platoon. The platoon then sets up a series of move orders to take them to the attack location.
Up until now the neural networks have not even come into play (although, that is one thing I would like to change in KnC). Once the platoon encounters an enemy it gathers information about the enemies in the area and it also gathers information about allies in the area. Note the difference between live and training. In training the platoon only gathers information about itself, in live the platoon gathers information about all allies (including player controlled units) in the area.
It then takes all of that information and feeds it into the input neurons of the neural network and feeds the network forward. It then gathers the outputs from the neural network and evaluates the output. Each output corresponds to an action that the platoon can take such as, attack structure from range or attack highest value target. Each output is going to have a value of between 0.0 and 1.0 with below 0.5 being a bad decision and above 0.5 being a good decision. If there are no good decisions returned by the neural network it means run away. After a small delay the enemy and ally data are gathered up again, feed to the neural network, and a new decision is made.
The neural networks are trained by having the AI fight it out repeatedly and backpropagating the results. At the end of a match the game writes out the new neural networks to a file. The game runs using a few special command lines which do the following:
- Set the game to run at +/- 50 sim speed.
- Automatically restart the game when it ends.
- Enable neural network training.
- Set which map to play on.
- Sets up the AIs.
Hopefully this answers most, if not all, the questions you all had.