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
902 stars 63 forks source link

Require sb3 version 2 or newer #148

Closed Ivan-267 closed 11 months ago

Ivan-267 commented 11 months ago

Our environment will not work with older sb3 versions, due to using gymnasium (where older sb3 versions used gym).

Edit: This may cause an issue with rllib, I will check the test results and see if it can be addressed if it does.

Ivan-267 commented 11 months ago

It seems that older Ray is installed on the tests that pass, so by specifying the gymnasium version we could be enforcing older Ray (which works with our config) to be installed. On the newer version of Ray, I also locally had some issues unless I try a different path format. Even outside of the path issue, I also had some issues with one of my environments with both Ray versions, something about the format of observations, but I didn't test it in-depth, so I don't know the issue was related to my Godot environment (which worked with SB3 which I mostly use for now), or something else.

I'll add the gymnasium version as a quick temporary fix, if it works, we can merge the PR for now since it's focused on ensuring the correct SB3 version, and in the future we can test our Ray configuration and see if something needs to be updated.

Edit: Still newer gymnasium with ray-2.7.0 is being installed, I'll have to look into this a bit more later.

Ivan-267 commented 11 months ago

With this approach, newer Ray 2.7 seems to work, although I didn't perform much testing to see if everything works with this as before. As a quick fix I've changed the folder path to an absolute path as that seems to fix the error. An alternative could be to use older Ray or find a different fix for the issue.

It should be noted that one of my environments didn't work with rllib (some observation type error), but I think that holds for both Ray versions, and may need more troubleshooting at some future point as I'm not sure about the cause yet (maybe something with the env itself even though it works with SB3). Jumperhard worked on my PC as well, but there might be some difference in observations from my env (which has some floats and a raycast obs array).

For future reference and in case similar errors appear in the future, the error was:

ValueError: The two structures don't have the same nested structure.

First structure: type=dict str={'obs': [0.0028, 0.000441726500866935, 0.00281361560337245, 0.00664886436425149, 0.260605245828629, 0.39156648516655, -0.00112051225733, -1.99999463558197, 0.781054401397705, 0.746744704246521, 0.712950587272644, 0.76171236038208, 0.769729685783386, 0.743742609024048, 0.659272933006287, 0.363503074645996, 0, 0.292076635360718, 0.415652275085449, 0.244122076034546, 0, 0.216817808151245, 0.643476295471191, 0.747096061706543, 0.781146144866943]}

Second structure: type=OrderedDict str=OrderedDict([('obs', array([-0.19811498,  0.8486953 ,  0.7596289 ,  0.2623617 , -0.08332985,
        0.21301392,  0.7458078 , -0.4820755 , -0.88564146, -0.6634987 ,
        0.82966214,  0.6683578 , -0.18554112, -0.7013975 ,  0.8797588 ,
       -0.24309783,  0.77364075,  0.4879668 , -0.982385  , -0.4481921 ,
        0.8362797 , -0.21034704,  0.9531232 , -0.33154443,  0.886062  ],
      dtype=float32))])

More specifically: Substructure "type=list str=[0.0028, 0.000441726500866935, 0.00281361560337245, 0.00664886436425149, 0.260605245828629, 0.39156648516655, -0.00112051225733, -1.99999463558197, 0.781054401397705, 0.746744704246521, 0.712950587272644, 0.76171236038208, 0.769729685783386, 0.743742609024048, 0.659272933006287, 0.363503074645996, 0, 0.292076635360718, 0.415652275085449, 0.244122076034546, 0, 0.216817808151245, 0.643476295471191, 0.747096061706543, 0.781146144866943]" is a sequence, while substructure "type=ndarray str=[-0.19811498  0.8486953   0.7596289   0.2623617  -0.08332985  0.21301392
  0.7458078  -0.4820755  -0.88564146 -0.6634987   0.82966214  0.6683578
 -0.18554112 -0.7013975   0.8797588  -0.24309783  0.77364075  0.4879668
 -0.982385   -0.4481921   0.8362797  -0.21034704  0.9531232  -0.33154443
  0.886062  ]" is not
Entire first structure:
{'obs': [., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., ., .]}
Entire second structure:
OrderedDict([('obs', .)])