skjb / pysc2-tutorial

Tutorials for building a PySC2 bot
https://medium.com/@skjb/building-a-basic-pysc2-agent-b109cde1477c
MIT License
287 stars 85 forks source link

Error getting Random Range. #2

Closed ghost closed 6 years ago

ghost commented 6 years ago

After i run the agent for a while i randomly get the following:

I1020 12:20:54.603614 12624 sc2_env.py:310] Episode finished. Outcome: [-1], reward: [-1], score: [1410] I1020 12:21:01.876163 12624 sc2_env.py:240] Starting episode: 6 Took 368.270 seconds for 9110 steps: 24.737 fps I1020 12:21:11.313090 12624 sc2_env.py:327] Environment Close I1020 12:21:11.315090 12624 sc2_env.py:342] Traceback (most recent call last): File "C:\Python36\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python36\lib\site-packages\pysc2\bin\agent.py", line 112, in app.run(main) File "C:\Python36\lib\site-packages\absl\app.py", line 272, in run _run_main(main, argv) File "C:\Python36\lib\site-packages\absl\app.py", line 237, in _run_main sys.exit(main(argv)) File "C:\Python36\lib\site-packages\pysc2\bin\agent.py", line 98, in main run_thread(agent_cls, FLAGS.map, FLAGS.render) File "C:\Python36\lib\site-packages\pysc2\bin\agent.py", line 77, in run_thread run_loop.run_loop([agent], env, FLAGS.max_agent_steps) File "C:\Python36\lib\site-packages\pysc2\env\run_loop.py", line 41, in run_loop for agent, timestep in zip(agents, timesteps)] File "C:\Python36\lib\site-packages\pysc2\env\run_loop.py", line 41, in for agent, timestep in zip(agents, timesteps)] File "C:\Python36\Lib\site-packages\pysc2\agents\smart_agent.py", line 177, in step i = random.randrange(0, len(unit_y) - 1) File "C:\Python36\lib\random.py", line 198, in randrange raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width)) ValueError: empty range for randrange() (0,0, 0) I1020 12:21:11.364095 12624 sc2_env.py:327] Environment Close I1020 12:21:11.365095 12624 sc2_env.py:342] I1020 12:21:11.367095 12624 sc2_env.py:327] Environment Close I1020 12:21:11.375099 12624 sc2_env.py:342] W1020 12:21:14.483033 12624 sc_process.py:183] Killing the process. I1020 12:21:15.275633 12624 sc_process.py:166] Shutdown with return code: 1

skjb commented 6 years ago

Hi @agent932, sorry about that, I noticed this bug after I published the article and haven't had time to go back in and fix it.

Replace that line with i = random.randint(0, len(unit_y) - 1). I have updated the code in the repository accordingly.