Package: godot-rl
Godot RL AgentsFeel free to join ourDiscordfor help and discussions about Godot RL Agents.Godot RL Agents is a fully Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents.
This repository provides:An interface between games created in theGodot Engineand Machine Learning algorithms running in PythonWrappers for four well known rl frameworks:StableBaselines3,Sample Factory,Ray RLLibandCleanRL.Support for memory-based agents, with LSTM or attention based interfacesSupport for 2D and 3D gamesA suite of AI sensors to augment your agent's capacity to observe the game worldGodot and Godot RL Agents are completely free and open source under the very permissive MIT license. No strings attached, no royalties, nothing.You can find out more about Godot RL agents in our AAAI-2022 Workshoppaper.https://user-images.githubusercontent.com/7275864/140730165-dbfddb61-cc90-47c7-86b3-88086d376641.mp4Quickstart GuideThis quickstart guide will get you up and running using the Godot RL Agents library with the StableBaselines3 backend, as this supports Windows, Mac and Linux. We suggest starting here and then trying out our Advanced tutorials when learning more complex agent behaviors.Installation and first trainingInstall the Godot RL Agents library. If you are new to Python or not using a virtual environment, it's highly recommended to create one usingvenvorCondato isolate your project dependencies.Once you have set up your virtual environment, proceed with the installation:pipinstallgodot-rlDownload one, or more ofexamples, such as BallChase, JumperHard, FlyBy.gdrl.env_from_hub-redbeeching/godot_rl_JumperHardYou may need to add run permissions on the game executable.chmod+xexamples/godot_rl_JumperHard/bin/JumperHard.x86_64Train and visualizegdrl--env=gdrl--env_path=examples/godot_rl_JumperHard/bin/JumperHard.x86_64--experiment_name=Experiment_01--vizIn editor interactive trainingYou can also train an agent in the Godot editor, without the need to export the game executable.Download the Godot 4 Game Engine fromhttps://godotengine.org/Open the engine and import the JumperHard example inexamples/godot_rl_JumperHardStart in editor training with:gdrlCreating a custom environmentThere is a dedicated tutorial on creating custom environmentshere. We recommend following this tutorial before trying to create your own environment.If you face any issues getting started, please reach out on ourDiscordor raise a GitHub issue.Exporting and loading your trained agent in onnx format:The latest version of the library provides experimental support for onnx models with the Stable Baselines 3 and rllib training frameworks.First run train you agent using the sb3 example on theGitHub repo, enabling the option--onnx_export_path=GameModel.onnxThen, using themono versionof the Godot Editor, add the onnx model path to the sync node. If you do not seen this option you may need to download the plugin fromsourceThe game should now load and run using the onnx model. If you are having issues building the project, ensure that the contents of the.csprojand.slnfiles in you project match that those of the pluginsource.Advanced usagehttps://user-images.githubusercontent.com/7275864/209160117-cd95fa6b-67a0-40af-9d89-ea324b301795.mp4Please ensure you have successfully completed the quickstart guide before following this section.Godot RL Agents supports 4 different RL training frameworks, the links below detail a more in depth guide of how to use a particular backend:StableBaselines3(Windows, Mac, Linux)SampleFactory(Mac, Linux)CleanRL(Windows, Mac, Linux)Ray rllib(Windows, Mac, Linux)ContributingWe welcome new contributions to the library, such as:New environments made in GodotImprovements to the readme filesAdditions to the python codebaseStart by forking the repo and then cloning it to your machine, creating a venv and performing an editable installation.# If you want to PR, you should fork the lib or ask to be a contibutor
git clone git@github.com:YOUR_USERNAME/godot_rl_agents.git
cd godot_rl_agents
python -m venv venv
pip install -e ".[dev]"
# check tests run
make testThen add your features.
Format your code with:make style
make qualityThen make a PR against main on the original repo.FAQWhy have we developed Godot RL Agents?The objectives of the framework are to:Provide a free and open source tool for Deep RL research and game development.Enable game creators to imbue their non-player characters with unique behaviors.Allow for automated gameplay testing through interaction with an RL agent.How can I contribute to Godot RL Agents?Please try it out, find bugs and either raise an issue or if you fix them yourself, submit a pull request.When will you be providing Mac support?This should now be working, let us know if you have any issues.Can you help with my game project?If the README and docs here not provide enough information, reach out to us onDiscordor GitHub and we may be able to provide some advice.How similar is this tool to Unity ML agents?We are inspired by the the Unity ML agents toolkit and aims to be a more compact, concise and hackable codebase, with little abstraction.LicenseGodot RL Agents is MIT licensed. See theLICENSE filefor details."Cartoon Plane" (https://skfb.ly/UOLT) by antonmoek is licensed under Creative Commons Attribution (http://creativecommons.org/licenses/by/4.0/).Citing Godot RL Agents@article{beeching2021godotrlagents,
  author={Beeching, Edward and Dibangoye, Jilles and
    Simonin, Olivier and Wolf, Christian},
title = {Godot Reinforcement Learning Agents},
journal = {{arXiv preprint arXiv:2112.03636.},
year = {2021},
}AcknowledgmentsWe thank the authors of the Godot Engine for providing such a powerful and flexible game engine for AI agent development.
We thank the developers at Sample Factory, Clean RL, Ray and Stable Baselines for creating easy to use and powerful RL training frameworks.
We thank the creators of the Unity ML Agents Toolkit, which inspired us to create this work.