oxwhirl / smac

SMAC: The StarCraft Multi-Agent Challenge
MIT License
1.07k stars 226 forks source link

showing gui #3

Closed esquires closed 3 years ago

esquires commented 5 years ago

Thanks for putting together this repo.

I am trying to figure out how to show a game window to see what is happening. When I run python -m smac.examples.random_agents or the sample program from the README, nothing seems to show up. Can you help me figure out what might be going wrong?

I am using Starcraft II v 4.7.1 and am on 7678571 in this repo. Here is the output when I run python -m smac.examples.random_agents. When I run python -m pysc2.bin.agent --map Simple64 from pysc2 a window seems to pop up fine (the render interface disabled line also shows up there too when I can see a gui).

Also, I noticed that nothing is showing up in ~/StarCraftII/Replays. Where does a replay show up? Thanks.

Version: B70326 (SC2.2018Season4)
Build: Nov 27 2018 03:26:30
Command Line: '"/home/esquires3/StarCraftII/Versions/Base70154/SC2_x64" -listen 127.0.0.1 -port 20293 -dataDir /home/esquires3/StarCraftII/ -tempDir /tmp/sc-5lbi516w/ -displayMode 0 -windowwidt
h 1920 -windowheight 1200 -windowx 50 -windowy 50 -eglpath libEGL.so'
Starting up...
Startup Phase 1 complete
Startup Phase 2 complete
Attempting to initialize EGL from file libEGL.so ...
Failed to find EGL functions in library file!
Creating stub renderer...
Listening on: 127.0.0.1:20293
Startup Phase 3 complete. Ready for commands.
Requesting to join a single player game
Configuring interface options
Configure: raw interface enabled
Configure: feature layer interface disabled
Configure: score interface disabled
Configure: render interface disabled
Entering load game phase.
Launching next game.
Next launch phase started: 2
Next launch phase started: 3
Next launch phase started: 4
Next launch phase started: 5
Next launch phase started: 6
Next launch phase started: 7
Next launch phase started: 8
Game has started.
Sending ResponseJoinGame
Total reward in episode 0 = 0.375
Total reward in episode 1 = 0.75
Total reward in episode 2 = 0.5625
Total reward in episode 3 = 0.9375
Total reward in episode 4 = 0.75
Total reward in episode 5 = 0.1875
Total reward in episode 6 = 0.9375
Total reward in episode 7 = 0.5625
Total reward in episode 8 = 0.5625
Total reward in episode 9 = 0.5625
RequestQuit command received.
Closing Application...
unable to parse websocket frame.
Terminate action already called.
Entering core terminate.
Core shutdown finished.
TimeBreaker commented 5 years ago

I have exactly the same problem. But when I try to run pysc2 by "python3 -m pysc2.bin.agent --map Simple64" the game runs normally.

eugenevinitsky commented 5 years ago

@esquires Did you install pysc2 as well?

samvelyan commented 5 years ago

Hi @esquires,

My sincere apologies for the late reply. Could you please specify which OS are you using? I'm certain that the older versions of pysc2 did not have a graphical component for SC2 on Linux. If there are any changes on their side and SC2 GUI can be turned on, I'll add the features in SMAC as well. Otherwise, the GUI should work fine on MacOS.

The replays should indeed appear in $SC2PATH/Replays directory. However, the random_agents script does not generate any replays. Please refer to pymarl README for guidelines on how to save SC2Replays.

esquires commented 5 years ago

No worries @samvelyan. I appreciate you following up. My confusion is mostly that the pysc2 command seems to produce a gui but the smac command does not. These are the last two commands below.

I am on Ubuntu 16.04 but have also tried it on 18.04. Here are a list of commands I did to get started:

# get starcraft
cd ~
wget http://blzdistsc2-a.akamaihd.net/Linux/SC2.4.7.1.zip
unzip -P iagreetotheeula SC2.4.7.1.zip

urls=(
    https://github.com/oxwhirl/smac/files/2760783/SMAC_Maps.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season1.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season2.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season3_Updated.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2017Season4.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season1.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season2_Updated.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season3.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2018Season4.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Ladder2019Season1.zip
    http://blzdistsc2-a.akamaihd.net/MapPacks/Melee.zip
)

for url in ${urls[@]}; do
    wget $url
    fname=$(echo $url | rev | cut -d '/' -f 1 | rev)
    unzip -P iagreetotheeula -d ~/StarCraftII/Maps  $fname 
done

wget https://github.com/deepmind/pysc2/releases/download/v1.2/mini_games.zip
unzip mini_games.zip -d ~/StarCraftII/Maps

# make a virtual environment
mkdir -p ~/venvs
cd ~/venvs
python3.5 -m venv smac2
source ~/venvs/smac2/bin/activate
pip install --upgrade wheel setuptools

# install latest version of pysc2 based on previous comment
mkdir ~/repos/rl -p
cd ~/repos/rl
git clone https://github.com/deepmind/pysc2
pip install -e pysc2

# install smac
cd ~/repos/rl
git clone https://github.com/oxwhirl/smac
pip install -e smac

# test installation
cd ~
python -m smac.bin.map_list # this one looks fine (no gui expected)
python -m smac.examples.random_agents # this one seems like it should have a gui but doesn't
python -m pysc2.bin.agent --map Simple64 # this one produces a gui
samvelyan commented 5 years ago

Many thanks for all the information @esquires. I'll take a close look at this and get back to you.

esquires commented 5 years ago

Hi @samvelyan . I see you added a help wanted label. Did you need any additional information from me?

samvelyan commented 5 years ago

Hi @esquires. No actually I've added the label to indicate that this is a 'help wanted'-kind of issue. Sorry for the confusion, I may have added a wrong label here.

esquires commented 5 years ago

Is there an object responsible for rendering in smac? I saw in the pysc2 code there is a RenderHuman object that gets it data from the controller but didn't see a corresponding object in the smac codebase.

samvelyan commented 5 years ago

No, we are not doing any rendering in SMAC.

Sorry, I've haven't been able to find time to look at this yet. Had a very hectic schedule during the past few weeks, and, unfortunately, during the next two weeks as well.

wyixiang commented 4 years ago

I have the same problem on Ubuntu 18.04. Is there any solution now?

ludovic-carre commented 4 years ago

The only way to watch a replay on SMAC is to play it from the windows game ? There is no way to watch it with deteriorated graphics as in pysc2 ? What is the meaning of the "watch a replay" section on README then ? I tried to naively watch a replay as you do in pysc2 and had the following error: File "/usr/local/lib/python3.7/site-packages/pysc2/lib/stopwatch.py", line 212, in _stopwatch return func(*args, **kwargs) File "/usr/local/lib/python3.7/site-packages/pysc2/lib/features.py", line 305, in color return self.palette[plane] IndexError: index 1970 is out of bounds for axis 0 with size 1962

samvelyan commented 4 years ago

Hi @esquires ,

I'm terribly sorry for getting back to you so late regarding this (OMG, it's been more than a year).

I've tried to replicate your results and followed your aforementioned steps on Ubuntu 16.04. Unfortunately, running the last command was unsuccessful for me. I specifically got this error, which doesn't seem to be solved yet.

Anyway, do you recall which GUI did you see? Is it StarCraft II window (bottom left) or StarCraft Viewer (top right)?

Screenshot 2020-08-04 at 16 42 09

The screen is from my MacOS laptop.

4ever-Rain commented 3 years ago

I have the same problem on Ubuntu 20.04, when I runpython -m smac.examples.random_agents However, when I run python -m pysc2.bin.agent --map Simple64 , I can see StarCraft Viewer (top right). @samvelyan I think pysc2 can work well by pip install pysc2 (v3.0.0) with the Starcraft II v 4.10

samvelyan commented 3 years ago

We now have pygame environment rendering, which can be used via the render() method (see example in the Readme). Please reopen if there are any issues.