Machine learning in a game

This is my 4th year project involving implementing Machine Learning into a game. I got interested in machine learning because of my work on the AI for To The Core, and in hindsight likely some other games where I worked on AI as well.

Working on the AI for To The core for half a year got me interested in persuing a personal project in AI. One of my teachers suggested I check out a course on Deep Learning on Coursera. After checking out this course I started it as part of my project, while continuing to find a way to train AI for a game with machine learning.

Eventually found the ML-Agents plugin for Unity, which is a a way to train neural networks for an AI in unity. Check out their GitHub page, with documentation on the plugin.

This gif shows a scene in unity that, with one of the example projects from te ML-Agents GitHub. After training this AI, it learns to recognize the colour of the block in the centre of the hallway, and move to the finish square with the corresponding colour. This works through reinforcement learning, which means it gets a reward when it reaches its goal, and a negative reward when it fails to reach its goal. The negative reward also increase with each time step, teaching it to reach the end as quickly as possible.

Fps Arena

the video below shows progress in the making of an Fps arena mini game. The AI is trained to shoot the targets, and avoid the red zones. All locations are randomized.

After having a decent result with shooting stating targets while avoiding red zones, I started to train them against another AI.  This enemy AI is set up to have the same neural network as the primary one, only this one will not learn. After running a training session the AI that is learning, will have learned to beat the non-learning AI.

At that point I change the network for the non-learning AI to the improved network and run again. Every other run, I change which AI is learning, so that the Neural Network won’t learn to depend on specific things.

The video below shows the AI trained against eachother.

If you would like to try it for yourself, you can! I created a playable version, which can be downloaded here.