google-deepmind / pysc2

StarCraft II Learning Environment
Apache License 2.0
8.04k stars 1.16k forks source link

just error in CollectMineralShards #53

Closed wwxFromTju closed 7 years ago

wwxFromTju commented 7 years ago

I can run other map just CollectMineralShards have problem. run agent and play is ok for other map.

but when I use CollectMineralShards, the window show the load, when load over, than cask: python -m pysc2.bin.agent --map CollectMineralShards NSWindowEdgeResizing is off! Traceback (most recent call last): File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 61, in catch_websocket_connection_errors yield File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 152, in _read response_str = self._sock.recv() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_core.py", line 293, in recv opcode, data = self.recv_data() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_core.py", line 310, in recv_data opcode, frame = self.recv_data_frame(control_frame) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_core.py", line 323, in recv_data_frame frame = self.recv_frame() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_core.py", line 357, in recv_frame return self.frame_buffer.recv_frame() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_abnf.py", line 340, in recv_frame self.recv_header() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_abnf.py", line 288, in recv_header header = self.recv_strict(2) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_abnf.py", line 375, in recvstrict bytes = self.recv(min(16384, shortage)) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_core.py", line 427, in _recv return recv(self.sock, bufsize) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/websocket/_socket.py", line 93, in recv "Connection is already closed.") websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/runpy.py", line 184, in _run_module_as_main "main", mod_spec) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/bin/agent.py", line 112, in app.run(main) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/app.py", line 57, in run really_start(main or sys.modules["main"].main) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/app.py", line 51, in really_start sys.exit(main(argv)) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/bin/agent.py", line 98, in main run_thread(agent_cls, FLAGS.map, FLAGS.render) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/bin/agent.py", line 74, in run_thread visualize=visualize) as env: File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/env/sc2_env.py", line 180, in init static_data = self._controller.data() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/remote_controller.py", line 151, in data return static_data.StaticData(self.data_raw()) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/remote_controller.py", line 80, in _valid_status return func(self, *args, kwargs) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/stopwatch.py", line 197, in _stopwatch return func(args, kwargs) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/remote_controller.py", line 147, in data_raw ability_id=True, unit_type_id=True)) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 127, in send res = self.send_req(sc_pb.Request(kwargs)) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 113, in send_req return self.read() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/stopwatch.py", line 197, in _stopwatch return func(args, kwargs) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 86, in read response = self._read() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 152, in _read response_str = self._sock.recv() File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/contextlib.py", line 77, in exit self.gen.throw(type, value, traceback) File "/Users/codeMan/anaconda3/envs/keras/lib/python3.5/site-packages/pysc2/lib/protocol.py", line 63, in catch_websocket_connection_errors raise ConnectionError("Connection already closed. SC2 probably crashed. " pysc2.lib.protocol.ConnectionError: Connection already closed. SC2 probably crashed. Check the error log.

wwxFromTju commented 7 years ago

I also map editor to create new map, the new map also can run. just CollectMineralShards have problem

tewalds commented 7 years ago

I can't replicate that problem, and unfortunately the error message you posted only says that SC2 quit or crashed. We'd need more details than that. One difference between that map and the rest is that it depends on one of the campaign mods. Are you using the starter edition?

4rChon commented 7 years ago

Hi, I am also getting a similar* error.

On Windows 10, with the latest expansion (Legacy of the Void), Python 3.5.3

python -m pysc2.bin.agent --map CollectMineralShards --agent pysc2.agents.scripted_agent.CollectMineralShards
Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 61, in catch_websocket_connection_errors
    yield
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 152, in _read
    response_str = self._sock.recv()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 293, in recv
    opcode, data = self.recv_data()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 310, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 323, in recv_data_frame
    frame = self.recv_frame()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 357, in recv_frame
    return self.frame_buffer.recv_frame()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 340, in recv_frame
    self.recv_header()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 288, in recv_header
    header = self.recv_strict(2)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 375, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 427, in _recv
    return recv(self.sock, bufsize)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_socket.py", line 80, in recv
    bytes_ = sock.recv(bufsize)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\bin\agent.py", line 112, in <module>
    app.run(main)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\app.py", line 57, in run
    really_start(main or sys.modules["__main__"].main)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\app.py", line 51, in really_start
    sys.exit(main(argv))
  File "C:\Program Files\Python35\lib\site-packages\pysc2\bin\agent.py", line 98, in main
    run_thread(agent_cls, FLAGS.map, FLAGS.render)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\bin\agent.py", line 74, in run_thread
    visualize=visualize) as env:
  File "C:\Program Files\Python35\lib\site-packages\pysc2\env\sc2_env.py", line 185, in __init__
    static_data = self._controller.data()
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 151, in data
    return static_data.StaticData(self.data_raw())
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 80, in _valid_status
    return func(self, *args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\stopwatch.py", line 197, in _stopwatch
    return func(*args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 147, in data_raw
    ability_id=True, unit_type_id=True))
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 127, in send
    res = self.send_req(sc_pb.Request(**kwargs))
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 113, in send_req
    return self.read()
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\stopwatch.py", line 197, in _stopwatch
    return func(*args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 86, in read
    response = self._read()
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 152, in _read
    response_str = self._sock.recv()
  File "C:\Program Files\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 66, in catch_websocket_connection_errors
    raise ConnectionError("Socket error: %s" % e)
pysc2.lib.protocol.ConnectionError: Socket error: [WinError 10054] An existing connection was forcibly closed by the remote host
4rChon commented 7 years ago

SC2 does not crash if I run the map directly from the sc2 map editor.

wwxFromTju commented 7 years ago

@4rChon Yes, When I use the map editor,the map than can use in pysc2.

fohria commented 7 years ago

I get the exact same error message as @4rChon on Windows 7 x64 and python 3.6.2. SC2 was installed and updated via Blizzard app today. Same for me that it's just CollectMineralShards having the issue.

inoryy commented 7 years ago

@tewalds this is most likely related to 3.17 patch.
It worked fine for me on 3.16.1 then crashed with same error as @4rChon after I updated to 3.17.

Additionally, it still works fine on Linux under 3.16.1 package.

taki0112 commented 7 years ago

I have the same error. Is it only in 3.17 version? Anyone know how to downgrade 3.16 ?

my environment : window7 64 bit python 3.5

Goleeb commented 7 years ago

I have the same issue: Window 10 64 bit python 3.5.2

I ran both "python -m pysc2.bin.agent --map CollectMineralShards" and "python -m pysc2.bin.agent --map CollectMineralShards --agent pysc2.agents.scripted_agent.CollectMineralShards" both ways produce the error. When I checked the SC2 error files in Documents\StarCraft II\GameLogs The DMP file shows this.

Exception Code: 0xC0000005

Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.

When I attached the visual studio debugger to SC2_x64.exe I get:

Exception thrown at 0x00007FF7489AE6B6 in SC2_x64.exe: 0xC0000005: Access violation reading location 0x0000000000000008. occurred

Now If in pysc2.bin.play on line 36 if I set render to False. The game loads with the python -m pysc2.bin.play --map CollectMineralShards Will load fine, and not crash.

Though if I change the same option in pysc2.bin.agent on line 37 I still get the same crash error.

It always happens as the game is done loading, and lead me to suspect a rendering issue,but im not familiar enough with the code to track it down yet.

KevinCalderone commented 7 years ago

I am able to reproduce this. I can look into it on Tuesday.

There is a way to downgrade back to 3.16.1 but it is a bit annoying since PySC2 hasn't added support for it.

A hacky way of doing it:

wwxFromTju commented 7 years ago

@KevinCalderone in Version, I just have Base56787, so what can I do?

KevinCalderone commented 7 years ago

Looked into this. There was a crash bug introduced in 3.17 when doing a "RequestData" query on a map using campaign mods. This should only impact the CollectMineralShards mini game map. (As tewalds mentioned, that is the only one that uses campaign data)

The fix has been implemented for the 3.18 release.

KevinCalderone commented 7 years ago

@wwxFromTju Here are some more details steps for the first bullet of my above steps:

  1. Download the 3.16.1 map pack. (Download Link)
  2. Extract one of the replays from the pack.
  3. Launch StarCraft II through the Blizzard app.
  4. Click on the "Replays" tab.
  5. Click on the "Show in Folder" button near the top. (This will open an explorer window to your replays folder)
  6. Copy the replay into this folder.
  7. In SC2, click on the "Multiplayer" tab and then the "Replays" tab again. (This will force it to refresh and show the replay you copied in)
  8. Double click on the replay name to play it.
  9. This will show an warning dialog saying you need to go offline to watch the replay. Press "Load" to continue.
  10. You will see a progress bar of it downloading the old version.

The old game version should now be downloaded, and you should see a Base55958 folder in your Versions folder.

wwxFromTju commented 7 years ago

@KevinCalderone When I unzip the zip, need password. So the password is what?

KevinCalderone commented 7 years ago

See: https://github.com/Blizzard/s2client-proto#downloads

Password is 'iagreetotheeula'

wwxFromTju commented 7 years ago

@KevinCalderone great! fix it!

skjb commented 7 years ago

@KevinCalderone I am getting this error playing replays too, not running the mineral shards map. I am unsure if the 3.18 fix resolves it so I thought I should report it. Replays worked before 3.17.

python` -m pysc2.bin.play --replay 0000e057beefc9b1e9da959ed921b24b9f0a31c63fedb8d94a1db78b58cf92c5.SC2Replay
----------------------- Replay info ------------------------
map_name: "Mech Depot LE"
player_info {
  player_info {
    player_id: 1
    race_requested: Protoss
    race_actual: Protoss
  }
  player_result {
    player_id: 1
    result: Defeat
  }
  player_mmr: 5402
  player_apm: 386
}
player_info {
  player_info {
    player_id: 2
    race_requested: Zerg
    race_actual: Zerg
  }
  player_result {
    player_id: 2
    result: Victory
  }
  player_mmr: 5564
  player_apm: 384
}
game_duration_loops: 20887
game_duration_seconds: 932.5204467773438
game_version: "3.16.1.55958"
data_build: 55958
base_build: 55958
data_version: "5BD7C31B44525DAB46E64C4602A81DC2"

------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 61, in catch_websocket_connection_errors
    yield
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 152, in _read
    response_str = self._sock.recv()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 293, in recv
    opcode, data = self.recv_data()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 310, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 323, in recv_data_frame
    frame = self.recv_frame()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 357, in recv_frame
    return self.frame_buffer.recv_frame()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 340, in recv_frame
    self.recv_header()
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 288, in recv_header
    header = self.recv_strict(2)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_abnf.py", line 375, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
  File "C:\Program Files\Python35\lib\site-packages\websocket\_core.py", line 427, in _recv
    return recv(self.sock, bufsize)
  File "C:\Program Files\Python35\lib\site-packages\websocket\_socket.py", line 93, in recv
    "Connection is already closed.")
websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files\Python35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\bin\play.py", line 183, in <module>
    app.run(main)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\app.py", line 57, in run
    really_start(main or sys.modules["__main__"].main)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\app.py", line 51, in really_start
    sys.exit(main(argv))
  File "C:\Program Files\Python35\lib\site-packages\pysc2\bin\play.py", line 141, in main
    controller.start_replay(start_replay)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 80, in _valid_status
    return func(self, *args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 55, in _check_error
    return check_error(func(*args, **kwargs), error_enum)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\stopwatch.py", line 197, in _stopwatch
    return func(*args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\remote_controller.py", line 134, in start_replay
    return self._client.send(start_replay=req_start_replay)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 127, in send
    res = self.send_req(sc_pb.Request(**kwargs))
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 113, in send_req
    return self.read()
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\stopwatch.py", line 197, in _stopwatch
    return func(*args, **kwargs)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 86, in read
    response = self._read()
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 152, in _read
    response_str = self._sock.recv()
  File "C:\Program Files\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Program Files\Python35\lib\site-packages\pysc2\lib\protocol.py", line 63, in catch_websocket_connection_errors
    raise ConnectionError("Connection already closed. SC2 probably crashed. "
pysc2.lib.protocol.ConnectionError: Connection already closed. SC2 probably crashed. Check the error log.
KevinCalderone commented 7 years ago

@skjb Does the game crash and bring up the Blizzard error reporter when that happens? If so can you submit the report and post the exception ID number it displays in that window.

KevinCalderone commented 7 years ago

@skjb Actually I just tested using that replay and can reproduce the issue. The problem is that PySC2 hasn't added support for old version replays yet. The game was recently patched to 3.17, and that replay is from 3.16.1.

If you really need it to work, there are some hacky steps to downgrade PySC2 back to the old version: https://github.com/deepmind/pysc2/issues/53#issuecomment-326829857

laksefest commented 7 years ago

@KevinCalderone Fantastic, thanks! That fixed it! :)

skjb commented 7 years ago

@KevinCalderone FYI Running 3.18.0.57507 I still get this error

KevinCalderone commented 7 years ago

Just retested and seem to work for me.

Does it still crash and bring up the error reporter? Can you submit the report and give me the Occurence Id it shows in the window?

skjb commented 7 years ago

Please see my error above regarding replays, I get an identical error.

This is what the game shows:

image

The game then restarts and shows:

image

KevinCalderone commented 7 years ago

Oh sorry I thought you were referencing the crash from the top of this issue.

My comment here is likely still accurate.

I still don't think PySC2 has added old version support yet. I see in your screenshot it is launching the 3.18 version of the game. Replays only work with the game version they originally were played on.

I defer to @tewalds on what the timeline for this is.

skjb commented 7 years ago

@KevinCalderone @tewalds I am happy to help with this if you need, seems for replays you would need the specific version in run_configs/platforms.py exec_path method rather than choosing the max version available

skjb commented 7 years ago

Game version parameter to allow for playing older replays: https://github.com/deepmind/pysc2/pull/79

tewalds commented 7 years ago

Ok, the code I just pushed fixes this in a few ways: Fixes the maps to not crash, lets you specify a game version, and will automatically launch the right version for a replay.