glmcdona / LuxPythonEnvGym

Matching python environment code for Lux AI 2021 Kaggle competition, and a gym interface for RL models.
MIT License
73 stars 38 forks source link

Rng fix broke code? #73

Closed royerk closed 2 years ago

royerk commented 2 years ago

@StoneT2000 I am not 100% sure where the issue is coming from but since I updated with the latest fix to the rng my code is crashing every time.

This is the error I have:

Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/multiprocessing/process.py", line 297, in _bootstrap
    self.run()
  File "/opt/conda/lib/python3.7/multiprocessing/process.py", line 99, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/conda/lib/python3.7/site-packages/stable_baselines3/common/vec_env/subproc_vec_env.py", line 33, in _worker
    observation = env.reset()
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/env/lux_env.py", line 88, in reset
    self.match_controller.reset()
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/match_controller.py", line 64, in reset
    self.game.reset()
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/game.py", line 105, in reset
    self.map.generate_map(self)
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/game_map.py", line 131, in generate_map
    half_height
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/game_map.py", line 266, in _generate_all_resources
    {"deathLimit": 1, "birthLimit": 6}
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/game_map.py", line 318, in _generate_resource_map
    if rng.random() < local_density:
  File "/opt/conda/lib/python3.7/site-packages/luxai2021-0.1.0-py3.7.egg/luxai2021/game/game_map.py", line 72, in _rng
    ret = rng_values[idx]
IndexError: list index out of range

Running with multiple cpus over millions of steps is almost certain to trigger this from what I have seen today.

StoneT2000 commented 2 years ago

oh dang ok I know the issue. In my PR i have the rng capped at 10000 uses thinking that's enough for the map generation, apparently not. I'll make a PR to up that to like 1000000 instead. For now you can edit yourself by changing the get_n_values call in the game_map.py file and change the number there

royerk commented 2 years ago

Great! Thanks for the quick feedback.

edit: testing now! seems to be running fine with a higher value :+1: