edbeeching / godot_rl_agents_examples

Example Environments for the Godot RL Agents library
MIT License
37 stars 13 forks source link

Adds item sorting cart example #15

Closed Ivan-267 closed 9 months ago

Ivan-267 commented 9 months ago

https://github.com/edbeeching/godot_rl_agents_examples/assets/61947090/c9d8b0f7-a6c9-455e-b5a4-c875b9b38648

(The same video is also added to the readme of the repository)

An example of a simpler environment that is relatively easy to train, with a couple of vector observations. The goal is to collect and drop off as many items as possible at the correct zone based on the current item's category within the episode step limit. If an item falls to the ground or the cart goes outside of the boundaries, the episode resets.

Uses a simple form of curriculum learning in the reward that encourages the cart to follow the position of the items (shaped reward) initially, and continues training on sparse rewards only after ~50 episodes for each instance. Keeping the shaped reward throughout training would possibly work well too, but I have not made a comparison.

There is an included onnx file trained for 2199384 steps using PPO with a single process from Godot Editor with sb3 (model = PPO("MultiInputPolicy", env, ent_coef=0.0005, n_steps=256, verbose=2, tensorboard_log=args.experiment_dir, learning_rate=linear_schedule(0.0003), n_epochs=7)). Opening the project and clicking "Play" in Godot should start the trained agent.

Project saved with Godot Godot_v4.2-rc2_mono_win64, it uses the newest plugin from the repository.

License for the assets is in the readme-license file as usual.

Ivan-267 commented 9 months ago

Possibly related to upgrading the project to Godot 4.2, there is a parse error for godot_rl_agents.gd when opening for the first time, but the project functions properly. Reopening the project removed the error for me.

Ivan-267 commented 9 months ago

I just tried to project, LGTM. Thanks

Thank you for the review, merging.