A Game AI implementation using Reinforcement Learning via ML-Agents in Unity.
Unity Version: 6000.0.31f1
You can open up Heuristic scene under Assets/Scenes to test the AI. However, if you'd like to train your own AI you can follow the steps below.
To do this you can look at Jeep.prefab under Assets/Prefabs, you'll need to set up your Agent in a similar way (hierarchy matters). Once you've your Agent set up, you can take a look at PlayerJeep.prefab and AiJeep_Training.prefab in the same directory to set up prefab variants for Player and AI respectively.
To do this you can look at Training scene under Assets/Scenes, you'll need to set up your Environments in a similar way. Each Environment has a Simulation script and a RandomTrackGenerator script attached to it, moreover it has a plane with a MeshCollider and a trainable Agent as child objects. The number of Environments you have will determine the number of Agents you can train simultaneously.
You can find the training config file under configs/ppo/kart-ai.yaml. You can change the values to suit your needs based on the ML-Agents documentation.
If you don't already have ML-Agents installed you can do so by following the instructions here. Once you've ML-Agents installed you can train your AI by running the following command in the terminal.
mlagents-learn <path-to-config-file> --run-id=<run-identifier>You can also find more information on training your Agent here.
Every configurable property for the Environment, Agent and Training has a tooltip you can access by hovering over it on the inspector.
If you would like to know how it works, I've a dev-log entry on it here
If you'd like to contribute to the project, you can fork the repository and create a pull request. You can also create an issue if you find any bugs or have any feature requests.