edbeeching / godot_rl_agents

An 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
MIT License
942 stars 69 forks source link

Not able to initiate training #202

Closed ra9hur closed 1 month ago

ra9hur commented 1 month ago

Environment:

I am following instructions as in the below link. https://github.com/edbeeching/godot_rl_agents/blob/main/docs/CUSTOM_ENV.md

Have setup all steps. I tried both the options.

Then run the project from Godot.

gdrl times out after a few seconds (approximately 30) with the below standard error. image

I checked the status of the port using netstat. image

There are no errors in Godot and ball moves randomly in 8 dummy envs. image

There are no related issues on github. So assume, it has been working all along, but I am missing something very obvious. Please help.

Ivan-267 commented 1 month ago

Hello,

Is there a sync node added to the scene you're starting and set to "training" mode (default)?

If so, could you try running one of the pre-made examples such as the BallChase env, just to see if everything works in that case, as the env should be ready for training: https://github.com/edbeeching/godot_rl_agents_examples/tree/main/examples/BallChase (you can download the entire examples repository as zip then open one of the projects such as BallChase in Godot Editor).

ra9hur commented 1 month ago

@Ivan-267 ,

Yes, sync is added with control mode set to training (default).

I tried BallChase env as you suggested. Everything works fine. There are a few differences when we load the project.

  1. A new build project icon image

  2. Server connection messages as highlighted were missing.

  3. A new MSBuild tab. This was again missing. image

Attaching the compressed project folder. RingPong.zip

Thanks for all the help !!

Ivan-267 commented 1 month ago

Hello,

I've taken a look at the project, to solve the issue, remove the _ready() method in res://controller.gd script and it should work.

The AIController3D class that is extended from has the following _ready() method already defined:

func _ready():
    add_to_group("AGENT")

This adds the AIController to the agent group, which is used by the sync node to detect it for training/inference/etc. If the method is overriden by the inheriting class, it won't add the AIController to the group (unless the line above is added), and so the sync node will not find any agents to train.

ra9hur commented 1 month ago

Got it, it works now. Thanks for your time !!

Ivan-267 commented 1 month ago

You're welcome. Closing this issue.