Skip to main content

A Deep Reinforcement Learning package for the Godot game engine

Project description

Godot RL Agents

Feel free to join our Discord for 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 the Godot Engine and Machine Learning algorithms running in Python
  • Wrappers for four well known rl frameworks: StableBaselines3, Sample Factory, Ray RLLib and CleanRL.
  • Support for memory-based agents, with LSTM or attention based interfaces
  • Support for 2D and 3D games
  • A suite of AI sensors to augment your agent's capacity to observe the game world
  • Godot 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 Workshop paper.

https://user-images.githubusercontent.com/7275864/140730165-dbfddb61-cc90-47c7-86b3-88086d376641.mp4

Quickstart Guide

This 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 training

  1. Install the Godot RL Agents library: (if you are new to python, pip and conda, read this guide)
pip install godot-rl
  1. Download one, or more of examples, such as BallChase, JumperHard, FlyBy.
gdrl.env_from_hub -r edbeeching/godot_rl_JumperHard 

You may need to example run permissions on the game executable. chmod +x examples/godot_rl_JumperHard/bin/JumperHard.x86_64

  1. Train and visualize
gdrl --env=gdrl --env_path=examples/godot_rl_JumperHard/bin/JumperHard.x86_64 --viz

In editor interactive training

You can also train an agent in the Godot editor, without the need to export the game executable.

  1. Download the Godot 4 Game Engine from https://godotengine.org/
  2. Open the engine and import the JumperHard example in examples/godot_rl_JumperHard
  3. Start in editor training with: gdrl

Creating a custom environment

There is a dedicated tutorial on creating custom environments here. We recommend following this tutorial before trying to create your own environment.

If you face any issues getting started, please reach out on our discord or 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.

  1. First run train you agent using the sb3 example on the github repo, enabling the option --onnx_export_path=GameModel.onnx
  2. Then, using the mono version of 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 from source
  3. The game should now load and run using the onnx model. If you are having issues building the project, ensure that the contents of the .csproj and .sln files in you project match that those of the plugin source.

Advanced usage

https://user-images.githubusercontent.com/7275864/209160117-cd95fa6b-67a0-40af-9d89-ea324b301795.mp4

Please 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:

FAQ

Why 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 on 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 ad hackable codebase, with little abstraction.

Licence

Godot RL Agents is MIT licensed. See the LICENSE file for 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},
}

Acknowledgments

We 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

godot_rl-0.5.0a0.tar.gz (23.9 kB view details)

Uploaded Source

Built Distribution

godot_rl-0.5.0a0-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file godot_rl-0.5.0a0.tar.gz.

File metadata

  • Download URL: godot_rl-0.5.0a0.tar.gz
  • Upload date:
  • Size: 23.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for godot_rl-0.5.0a0.tar.gz
Algorithm Hash digest
SHA256 3d4a9e364a64afd083327d40f7e8696538d98ecc68693f3a4234b13cf0d6bebb
MD5 f5c3201b02fb178c1db5ca6fc81c7989
BLAKE2b-256 549cce7791d1699ca60d2c5fa53afa098423a4b47a72f985b96ce1e22ed22f6b

See more details on using hashes here.

File details

Details for the file godot_rl-0.5.0a0-py3-none-any.whl.

File metadata

  • Download URL: godot_rl-0.5.0a0-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for godot_rl-0.5.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a1d110aa836a2b9738dea76abee84a33e35d6df9ea5ebc9385d17290ca5695f
MD5 53524674ccd9f0073687ba992c216fb2
BLAKE2b-256 eaf4211df084fb3a50b14cafeb96a172f655bd8edb3c73365c013afc2c42298a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page