Skip to content

Commit

Permalink
Merge pull request Farama-Foundation#176 from mwydmuch/cig2017
Browse files Browse the repository at this point in the history
CIG 2017 changes

Former-commit-id: 5800205
  • Loading branch information
mwydmuch authored Mar 24, 2017
2 parents 2bf0fad + a2cb602 commit 58d8063
Show file tree
Hide file tree
Showing 31 changed files with 336 additions and 48 deletions.
10 changes: 10 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog

## Changes in 1.1.2

#### Multiplayer
- Added `viz_respawn_delay` CVAR, which allows to control delay between respawns in multiplayer game.
- Added `viz_spectator` CVAR which allows to connect to multiplayer game as a spectator.
- Maximum number of connected players raised to 16.


## Changes in 1.1.1

#### GameState
- Added `tic` field.
- `GameVariable.DEATHCOUNT` fixed.

#### Lua specific
Expand Down Expand Up @@ -65,6 +74,7 @@ recording `filePath` argument added to `newEpisode`, `replayEpisode` added.
- Bugs associated with paths handling fixed.
- Many minor bugs fixed.
- Possibility to change scenario wad during runtime (only first map from WAD file).
- Added `viz_debug` CVAR to control some diagnostic massages.


#### C++ specific
Expand Down
92 changes: 92 additions & 0 deletions docker/tensorflow/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
FROM ubuntu:16.04 # CPU ONLY

# GPU -> see: https://github.com/NVIDIA/nvidia-docker
#FROM nvidia/cuda:7.5-cudnn5-devel
# or
#FROM nvidia/cuda:8.0-cudnn5-devel

# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
bzip2 \
cmake \
curl \
git \
libboost-all-dev \
libbz2-dev \
libfluidsynth-dev \
libfreetype6-dev \
libgme-dev \
libgtk2.0-dev \
libjpeg-dev \
libopenal-dev \
libpng12-dev \
libsdl2-dev \
libwildmidi-dev \
libzmq3-dev \
nano \
nasm \
pkg-config \
python-dev \
python \
rsync \
software-properties-common \
sudo \
tar \
timidity \
unzip \
wget \
zlib1g-dev


# Pick up pip
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py

# Install more dependencies via pip
RUN pip --no-cache-dir install \
ipykernel \
jupyter \
matplotlib \
numpy \
scipy \
sklearn \
pandas \
Pillow \

# Install TensorFlow
RUN pip --no-cache-dir install http://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
# or
#RUN pip --no-cache-dir install http://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl

# Clone ViZDoom and build + install via pip
RUN git clone https://github.com/mwydmuch/ViZDoom.git /root/vizdoom && \
pip install git+file:///root/vizdoom

# Expose ViZDoom's multiplayer port
EXPOSE 5029

# Code below allows sharing X11 socket with container
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer

USER developer
ENV HOME /home/developer

# Set workdir
WORKDIR /root/vizdoom/examples/pyhton

# Expose python command
CMD ["python"]

# Examples of usage:
# BUILD THIS DOCKER: docker build -t tf+vizdoom .
# RUN THIS DOCKER WITH X11: docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix tf+vizdoom python basic.py

86 changes: 86 additions & 0 deletions docker/torch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
FROM ubuntu:16.04 # CPU ONLY

# GPU -> see: https://github.com/NVIDIA/nvidia-docker
#FROM nvidia/cuda:7.5-cudnn5-devel
# or
#FROM nvidia/cuda:8.0-cudnn5-devel

# Install all dependencies
RUN apt-get update && apt-get install -y \
build-essential \
bzip2 \
cmake \
git \
libboost-all-dev \
libbz2-dev \
libfluidsynth-dev \
libgme-dev \
libgtk2.0-dev \
libjpeg-dev \
libopenal-dev \
libsdl2-dev \
libwildmidi-dev \
nasm \
nano \
sudo \
tar \
timidity \
unzip \
wget \
zlib1g-dev

# Clone Torch, install dependencies and build Torch (building blas may take a while)
RUN git clone https://github.com/torch/distro.git /root/torch --recursive && \
cd /root/torch && \
bash install-deps && \
./install.sh

# Export environment variables manually
ENV LUA_PATH='/root/.luarocks/share/lua/5.1/?.lua;/root/.luarocks/share/lua/5.1/?/init.lua;/root/torch/install/share/lua/5.1/?.lua;/root/torch/install/share/lua/5.1/?/init.lua;./?.lua;/root/torch/install/share/luajit-2.1.0-beta1/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua'
ENV LUA_CPATH='/root/.luarocks/lib/lua/5.1/?.so;/root/torch/install/lib/lua/5.1/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so'
ENV PATH=/root/torch/install/bin:$PATH
ENV LD_LIBRARY_PATH=/root/torch/install/lib:$LD_LIBRARY_PATH
ENV DYLD_LIBRARY_PATH=/root/torch/install/lib:$DYLD_LIBRARY_PATH
ENV LUA_CPATH='/root/torch/install/lib/?.so;'$LUA_CPATH
ENV TERM xterm

# Install more dependencies via luarocks
RUN luarocks install torchffi && \
luarocks install image

# Install CUDA libraries
RUN luarocks install cutorch && \
luarocks install cunn && \
luarocks install cudnn

# Clone ViZDoom and build + install via luarocks
RUN git clone https://github.com/mwydmuch/ViZDoom.git /root/vizdoom && \
cd /root/vizdoom && \
luarocks make

# Expose ViZDoom's multiplayer port
EXPOSE 5029

# Code below allows sharing X11 socket with container
# Replace 1000 with your user / group id
RUN export uid=1000 gid=1000 && \
mkdir -p /home/developer && \
echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
echo "developer:x:${uid}:" >> /etc/group && \
echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
chmod 0440 /etc/sudoers.d/developer && \
chown ${uid}:${gid} -R /home/developer

USER developer
ENV HOME /home/developer

# Set workdir
WORKDIR /root/vizdoom/examples/lua

# Expose th command
CMD ["th"]

# Examples of usage:
# BUILD THIS DOCKER: docker build -t torch+vizdoom .
# RUN THIS DOCKER WITH X11: docker run -ti --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix torch+vizdoom th basic.lua

3 changes: 2 additions & 1 deletion examples/c++/CIGBots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ int main(){

// Start multiplayer game only with Your AI (with options that will be used in the competition, details in CIGHost example).
game->addGameArgs("-host 1 -deathmatch +timelimit 1.0 "
"+sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1");
"+sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1 +sv_nocrouch 1 "
"+viz_respawn_delay 10 +viz_nocheat 1");

// Name your agent and select color
// colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
Expand Down
2 changes: 2 additions & 0 deletions examples/c++/CIGHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ int main(){
"+sv_noautoaim 1 " // Autoaim is disabled for all players.
"+sv_respawnprotect 1 " // Players will be invulnerable for two second after spawning.
"+sv_spawnfarthest 1 " // Players will be spawned as far as possible from any other players.
"+sv_nocrouch 1 " // Disables crouching.
"+viz_respawn_delay 10 " // Sets delay between respanws (in seconds).
"+viz_nocheat 1"); // Disables depth and labels buffer and the ability to use commands that could interfere with multiplayer game.

// Name your agent and select color
Expand Down
4 changes: 2 additions & 2 deletions examples/c++/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ To run the examples, [freedoom2.wad]( https://freedoom.github.io/download.html)
Demonstrates how to use the most basic features of the environment. It configures the engine, and makes the agent perform random actions. It also prints the current state and the reward earned with every action.

###[CIG.cpp](https://github.com/Marqt/ViZDoom/blob/master/examples/c++/CIG.cpp), [CIGHost.cpp](https://github.com/Marqt/ViZDoom/blob/master/examples/c++/CIGHost.cpp)
Demonstrates how to configure and play multiplayer game for CIG 2016 competition.
Demonstrates how to configure and play multiplayer game for CIG competition.

###[CIGBots.cpp](https://github.com/Marqt/ViZDoom/blob/master/examples/c++/CIGBots.cpp)
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG 2016 competition.
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG competition.

###[DeltaButtons.cpp](https://github.com/Marqt/ViZDoom/blob/master/examples/c++/DeltaButtons.cpp)
Shows how delta buttons work (they may take values other than 0 and 1 and can be used for precise movement).
Expand Down
4 changes: 2 additions & 2 deletions examples/java/CIG.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class CIG {

public static void main (String[] args) {

DoomGame game = new DoomGame();

System.out.println("\n\nCIG EXAMPLE\n");


DoomGame game = new DoomGame();

// Use CIG example config or Your own.
game.loadConfig("../../scenarios/cig.cfg");

Expand Down
9 changes: 6 additions & 3 deletions examples/java/CIGBots.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ public class CIGBots {

public static void main (String[] args) {

DoomGame game = new DoomGame();

System.out.println("\n\nCIG BOTS EXAMPLE\n");


DoomGame game = new DoomGame();

// Use CIG example config or Your own.
game.loadConfig("../../scenarios/cig.cfg");

Expand All @@ -22,7 +23,9 @@ public static void main (String[] args) {
//game.setDoomMap("map02"); // Full deathmatch.

// Start multiplayer game only with Your AI (with options that will be used in the competition, details in CIGHost example).
game.addGameArgs("-host 1 -deathmatch +timelimit 1.0 +sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1");
game.addGameArgs("-host 1 -deathmatch +timelimit 1.0 "
+ "+sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1 +sv_nocrouch 1 "
+ "+viz_respawn_delay 10 +viz_nocheat 1");

// Name your agent and select color
// colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
Expand Down
20 changes: 11 additions & 9 deletions examples/java/CIGHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ public class CIGHost {

public static void main (String[] args) {

DoomGame game = new DoomGame();

System.out.println("\n\nCIG HOST EXAMPLE\n");


DoomGame game = new DoomGame();

// Use CIG example config or Your own.
game.loadConfig("../../scenarios/cig.cfg");

Expand All @@ -24,13 +24,15 @@ public static void main (String[] args) {

// Host game with options that will be used in the competition.
game.addGameArgs("-host 8 " // This machine will function as a host for a multiplayer game with this many players (including this machine). It will wait for other machines to connect using the -join parameter and then start the game when everyone is connected.
+"-deathmatch " // Deathmatch rules are used for the game.
+"+timelimit 10.0 " // The game (episode) will end after this many minutes have elapsed.
+"+sv_forcerespawn 1 " // Players will respawn automatically after they die.
+"+sv_noautoaim 1 " // Autoaim is disabled for all players.
+"+sv_respawnprotect 1 " // Players will be invulnerable for two second after spawning.
+"+sv_spawnfarthest 1 " // Players will be spawned as far as possible from any other players.
+"+viz_nocheat 1"); // Disables depth and labels buffer and the ability to use commands that could interfere with multiplayer game.
+ "-deathmatch " // Deathmatch rules are used for the game.
+ "+timelimit 10.0 " // The game (episode) will end after this many minutes have elapsed.
+ "+sv_forcerespawn 1 " // Players will respawn automatically after they die.
+ "+sv_noautoaim 1 " // Autoaim is disabled for all players.
+ "+sv_respawnprotect 1 " // Players will be invulnerable for two second after spawning.
+ "+sv_spawnfarthest 1 " // Players will be spawned as far as possible from any other players.
+ "+sv_nocrouch 1 " // Disables crouching.
+ "+viz_respawn_delay 10 " // Sets delay between respanws (in seconds).
+ "+viz_nocheat 1"); // Disables depth and labels buffer and the ability to use commands that could interfere with multiplayer game.

// Name your agent and select color
// colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
Expand Down
4 changes: 2 additions & 2 deletions examples/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ To run the examples, [freedoom2.wad]( https://freedoom.github.io/download.html)
Demonstrates how to use the most basic features of the environment. It configures the engine, and makes the agent perform random actions. It also prints the current state and the reward earned with every action.

###[CIG.java](https://github.com/Marqt/ViZDoom/blob/master/examples/java/CIG.java), [CIGHost.java](https://github.com/Marqt/ViZDoom/blob/master/examples/java/CIGHost.java)
Demonstrates how to configure and play multiplayer game for CIG 2016 competition.
Demonstrates how to configure and play multiplayer game for CIG competition.

###[CIGBots.java](https://github.com/Marqt/ViZDoom/blob/master/examples/java/CIGBots.java)
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG 2016 competition.
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG competition.

###[DeltaButtons.java](https://github.com/Marqt/ViZDoom/blob/master/examples/java/DeltaButtons.java)
Shows how delta buttons work (they may take values other than 0 and 1 and can be used for precise movement).
Expand Down
2 changes: 1 addition & 1 deletion examples/lua/cig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ while not game:isEpisodeFinished() do
game:respawnPlayer()
end

print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
--print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
end

game:close()
8 changes: 4 additions & 4 deletions examples/lua/cig_bots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ game:setDoomMap("map01") -- Limited deathmatch.

-- Start multiplayer game only with your AI (with options that will be used in the competition, details in cig_host example).
game:addGameArgs("-host 1 -deathmatch +timelimit 1 " ..
"+sv_forcerespawn 1 +sv_noautoaim 1 " ..
"+sv_respawnprotect 1 +sv_spawnfarthest 1")
"+sv_forcerespawn 1 +sv_noautoaim 1 +sv_respawnprotect 1 +sv_spawnfarthest 1 +sv_nocrouch 1 " ..
"+viz_respawn_delay 10 +viz_nocheat 1")

-- Name your agent and select color
-- colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
game:addGameArgs("+name AI +colorset 0")

game:setMode(vizdoom.Mode.PLAYER)
game:setMode(vizdoom.Mode.SPECTATOR)
--game:setWindowVisible(false)

game:init();
Expand Down Expand Up @@ -71,7 +71,7 @@ for i = 1, episodes do
game:respawnPlayer()
end

print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
--print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
end

print("Episode finished.")
Expand Down
7 changes: 6 additions & 1 deletion examples/lua/cig_host.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ game:addGameArgs("-host 2 " .. -- This machine will function as a h
"+sv_noautoaim 1 " .. -- Autoaim is disabled for all players.
"+sv_respawnprotect 1 " .. -- Players will be invulnerable for two second after spawning.
"+sv_spawnfarthest 1 " .. -- Players will be spawned as far as possible from any other players.
"+sv_nocrouch 1" .. -- Disables crouching.
"+viz_respawn_delay 10 " ..-- Sets delay between respanws (in seconds).
"+viz_nocheat 1") -- Disables depth and labels buffer and the ability to use commands that could interfere with multiplayer game.

-- This can be used to host game without taking part in it (can be simply added as argument of vizdoom executable).
--game:add_game_args("viz_spectator 1")

-- Name your agent and select color
-- colors: 0 - green, 1 - gray, 2 - brown, 3 - red, 4 - light gray, 5 - light brown, 6 - light red, 7 - light blue
game:addGameArgs("+name AI +colorset 0")
Expand Down Expand Up @@ -58,7 +63,7 @@ while not game:isEpisodeFinished() do
game:respawnPlayer()
end

print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
--print("Frags:", game:getGameVariable(vizdoom.GameVariable.FRAGCOUNT))
end

game:close()
4 changes: 2 additions & 2 deletions examples/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Demonstrates how to use the most basic features of the environment. It configure
###[buffers.py](https://github.com/Marqt/ViZDoom/blob/master/examples/python/buffers.py)

###[cig.py](https://github.com/Marqt/ViZDoom/blob/master/examples/python/cig.py), [cig_host.py](https://github.com/Marqt/ViZDoom/blob/master/examples/python/cig_host.py)
Demonstrates how to configure and play multiplayer game for CIG 2016 competition.
Demonstrates how to configure and play multiplayer game for CIG competition.

###[cig_bots.py](https://github.com/Marqt/ViZDoom/blob/master/examples/python/cig_bots.py)
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG 2016 competition.
Demonstrates how to play with bots to simulate multiplayer game. Helpful for developing AI agent for CIG competition.

###[delta_buttons.py](https://github.com/Marqt/ViZDoom/blob/master/examples/python/delta_buttons.py)
Shows how delta buttons work (they may take values other than 0 and 1 and can be used for precise movement).
Expand Down
Loading

0 comments on commit 58d8063

Please sign in to comment.