Skip to content

Commit

Permalink
Merge pull request #521 from Farama-Foundation/clean_up
Browse files Browse the repository at this point in the history
Clean up of the code base
  • Loading branch information
mwydmuch authored Jan 7, 2023
2 parents 6e25a83 + a754dc3 commit 53b5eb3
Show file tree
Hide file tree
Showing 62 changed files with 171 additions and 18,467 deletions.
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set(ViZDoom_VERSION_ID ${ViZDoom_VERSION_MAJOR}${ViZDoom_VERSION_MINOR}${ViZDoom
# Building options
#-----------------------------------------------------------------------------------------------------------------------

option(BUILD_PYTHON "Build ViZDoom Python (3) binding" OFF)
option(BUILD_JULIA "Build ViZDoom Julia binding." OFF)
option(BUILD_PYTHON "Build ViZDoom Python (3) binding" ON)
option(BUILD_ENGINE "Build ViZDoom Engine" ON)


# CMake options
Expand Down Expand Up @@ -86,7 +86,7 @@ if (MSVC)
endif ()


# Main library and engine
# Main library
#-----------------------------------------------------------------------------------------------------------------------

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Expand Down Expand Up @@ -155,17 +155,16 @@ set_target_properties(libvizdoom_shared
PROPERTIES
PROJECT_LABEL "shared library")


# ViZDoom Engine
#-----------------------------------------------------------------------------------------------------------------------

add_subdirectory(${VIZDOOM_SRC_DIR}/vizdoom)


# Python and Julia
# Python bindings
#-----------------------------------------------------------------------------------------------------------------------

if (BUILD_PYTHON)
add_subdirectory(${VIZDOOM_SRC_DIR}/lib_python)
endif ()

if (BUILD_JULIA)
add_subdirectory(${VIZDOOM_SRC_DIR}/lib_julia)
endif ()

26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ ViZDoom is based on [ZDoom](https://github.com/rheit/zdoom) to provide the game

## Features
- Multi-platform (Linux, macOS, Windows),
- API for Python, C++, and Julia (thanks to [Jun Tian](https://github.com/findmyway)), and also Lua and Java for older versions,
- API for Python and C++,
- [OpenAI Gym](https://www.gymlibrary.dev/) environment wrappers (thanks to [Benjamin Noah Beal](https://github.com/bebeal), [Lawrence Francis](https://github.com/ldfrancis), and [Mark Towers](https://github.com/pseudo-rnd-thoughts)),
- Easy-to-create custom scenarios (visual editors, scripting language and examples available),
- Async and sync single-player and multi-player modes,
- Easy-to-create custom scenarios (visual editors, scripting language, and examples available),
- Async and sync single-player and multiplayer modes,
- Fast (up to 7000 fps in sync mode, single-threaded),
- Lightweight (few MBs),
- Customizable resolution and rendering parameters,
- Access to the depth buffer (3D vision),
- Automatic labelling game objects visible in the frame,
- Automatic labeling of game objects visible in the frame,
- Access to the audio buffer (thanks to [Shashank Hegde](https://github.com/hegde95)),
- Access to the list of actors/objects and map geometry,
- Off-screen rendering,
Expand All @@ -26,6 +26,8 @@ ViZDoom is based on [ZDoom](https://github.com/rheit/zdoom) to provide the game

ViZDoom API is **reinforcement learning** friendly (suitable also for learning from demonstration, apprenticeship learning or apprenticeship via inverse reinforcement learning, etc.).

Julia (thanks to [Jun Tian](https://github.com/findmyway)), Lua, and Java bindings are available in other branches but are no longer maintained.


## Cite as
> M Wydmuch, M Kempka & W Jaśkowski, ViZDoom Competitions: Playing Doom from Pixels, IEEE Transactions on Games, vol. 11, no. 3, pp. 248-259, 2019
Expand Down Expand Up @@ -67,7 +69,7 @@ or
### Ubuntu
To install ViZDoom on Ubuntu run (may take few minutes):
```
sudo apt install cmake libboost-all-dev libsdl2-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libjpeg-dev libbz2-dev libfluidsynth-dev libgme-dev libopenal-dev zlib1g-dev timidity tar nasm
sudo apt install cmake libboost-all-dev libsdl2-dev libfreetype6-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libjpeg-dev libbz2-dev libfluidsynth-dev libgme-dev libopenal-dev zlib1g-dev timidity tar
pip install vizdoom
```
We recommend using at least Ubuntu 18.04+ with Python 3.7+.
Expand All @@ -83,27 +85,22 @@ python setup.py build && python setup.py install
Note that `pip install vizdoom` won't work with conda install and you have to follow these steps.

### macOS
To install ViZDoom on macOS (Intel) run (may take few minutes):
To install ViZDoom on macOS (for Intel and Apple Silicon) run (may take few minutes):
```
brew install cmake boost openal-soft sdl2
pip install vizdoom
```
We recommend using at least macOS High Sierra 10.13+ with Python 3.7+.

To install ViZDoom on macOS with Apple Silicon (M1 or M2) run:
```
brew install cmake boost openal-soft sdl2
pip install git+https://github.com/mwydmuch/ViZDoom.git
```
On Apple Silicon (M1 and M2), make sure you are using Python for Apple Silicon.

### Windows
To install pre-build release for Windows 10 or 11 64-bit and Python 3.6+ just run (should take few seconds):
To install pre-build release for Windows 10 or 11 64-bit and Python 3.7+ just run (should take few seconds):
```
pip install vizdoom
```

### Gym wrappers
If you wish to use OpenAI Gym environments, install ViZDoom with
If you wish to also install OpenAI Gym environments, install ViZDoom with
```
pip install vizdoom[gym]
```
Expand All @@ -114,7 +111,6 @@ See [documentation](doc/Gym.md) and [examples](examples/python/gym_wrapper.py) o

- [Python](examples/python) (contain learning examples implemented in PyTorch, TensorFlow and Theano)
- [C++](examples/c%2B%2B)
- [Julia](examples/julia)

Python examples are currently the richest, so we recommend to look at them, even if you plan to use other language. API is almost identical for all languages.

Expand Down
86 changes: 20 additions & 66 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

## <a name="deps"></a> Dependencies

Even if you plan to install ViZDoom via PyPI or LuaRocks, you need to install some dependencies in your system first.
Even if you plan to install ViZDoom via PyPI you need to install some dependencies in your system first.


### <a name="linux_deps"></a> Linux
* CMake 3.1+
* CMake 3.4+
* Make
* GCC 6.0+
* Boost libraries 1.65.0+
* Python 3.5+ with Numpy for Python binding (optional)
* Python 3.7+ for Python binding (optional)

Additionally, [ZDoom dependencies](http://zdoom.org/wiki/Compile_ZDoom_on_Linux) are needed.

Expand All @@ -40,14 +40,7 @@ sudo apt-get install libboost-all-dev

# Python 3 dependencies
sudo apt-get install python3-dev python3-pip
pip3 install numpy
# or install Anaconda 3 and add it to PATH

# Julia dependencies
sudo apt-get install julia
julia
julia> using Pkg
julia> Pkg.add("CxxWrap")
```

If you do not have a root access, you can use a conda (e.g. [miniconda](https://docs.conda.io/en/latest/miniconda.html)) environment to install dependencies to your environment only:
Expand All @@ -64,10 +57,10 @@ python setup.py build && python setup.py install


### <a name="macos_deps"></a> MacOS
* CMake 3.1+
* CMake 3.4+
* Clang 5.0+
* Boost libraries 1.65.0+
* Python 3.5+ with Numpy for Python binding (optional)
* Python 3.7+ for Python binding (optional)

Additionally, [ZDoom dependencies](http://zdoom.org/wiki/Compile_ZDoom_on_Mac_OS_X) are needed.

Expand All @@ -77,27 +70,19 @@ To get dependencies install [homebrew](https://brew.sh/)
# ZDoom dependencies and Boost libraries
brew install cmake boost openal-soft sdl2

# Python 3 dependencies
brew install python3
pip3 install numpy
# or install Anaconda 3 and add it to PATH

# Julia dependencies
brew cask install julia
julia
julia> using Pkg
julia> Pkg.add("CxxWrap")
# You can use system python or install Anaconda 3 and add it to PATH
```


### <a name="windows_deps"></a> Windows
* CMake 3.1+
* CMake 3.4+
* Visual Studio 2012+
* Boost 1.65+
* Python 3.5+ with Numpy for Python binding (optional)
* Python 3.7+ for Python binding (optional)

Additionally, [ZDoom dependencies](http://zdoom.org/wiki/Compile_ZDoom_on_Windows) are needed.
Most of them are gathered in this repository: [ViZDoomWinDepBin](https://github.com/mwydmuch/ViZDoomWinDepBin).
Most of them (except Boost) are gathered in this repository: [ViZDoomWinDepBin](https://github.com/mwydmuch/ViZDoomWinDepBin).
You can download Boost from [here](https://www.boost.org/users/download).


## <a name="pypi"></a> Installation via PyPI (recommended for Python users)
Expand All @@ -118,18 +103,10 @@ pip install git+https://github.com/mwydmuch/ViZDoom.git
```


## <a name="windows_bin"></a> Installation of Windows binaries

For Windows we are providing a compiled environment that can be download from [releases](https://github.com/mwydmuch/ViZDoom/releases) page.
To install it for Python, copy files to `site-packages` folder.

Location of `site-packages` depends on Python distribution:
- Python: `python_root\Lib\site-packges`
- Anaconda: `anaconda_root\lib\pythonX.X\site-packages`


## <a name="build"></a> Building

Instructions below can be used to build ViZDoom manually.

### <a name="linux_build"></a> Linux

>>> Using [pip/conda](#pypi) is the recommended way to install ViZDoom, please try it first unless you are sure you want to compile the package by hand.
Expand All @@ -138,22 +115,11 @@ In ViZDoom's root directory:
```bash
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=ON -DBUILD_JAVA=ON -DBUILD_LUA=ON -DBUILD_JULIA=ON
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_ENGINE=ON -DBUILD_PYTHON=ON
make
```

where `-DBUILD_PYTHON=ON` and `-DBUILD_JULIA=ON` CMake options for Python and Julia bindings are optional (default OFF). To force building bindings for Python3 instead of the first version found use `-DBUILD_PYTHON3=ON`.

To build Julia binding you first need to install CxxWrap package by running `julia` and using `Pkg.add("CxxWrap")` command (see [Linux dependencies](#linux_deps)). Then you need to manually set `JlCxx_DIR` variable:

```sh
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DBUILD_JULIA=ON \
-DJlCxx_DIR=~/.julia/vX.X/CxxWrap/deps/usr/lib/cmake/JlCxx/
```

where `-DBUILD_ENGINE=ON` and `-DBUILD_PYTHON=ON` CMake options are optional (default ON).

### <a name="macos_build"></a> MacOS

Expand All @@ -164,15 +130,15 @@ Run CMake and build generated Makefile.
```sh
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=ON -DBUILD_JULIA=ON
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_ENGINE=ON -DBUILD_PYTHON=ON
make
```

where `-DBUILD_PYTHON=ON` and `-DBUILD_JULIA=ON` CMake options for Python and Julia bindings are optional (default OFF). To force building bindings for Python3 instead of the first version found use `-DBUILD_PYTHON3=ON`.
where `-DBUILD_ENGINE=ON` and `-DBUILD_PYTHON=ON` CMake options are optional (default ON).

Users with brew-installed Python/Anaconda **may** need to manually set `PYTHON_EXECUTABLE`, `PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARY` variables:
Users with brew-installed Python/Anaconda **may** (in some cases) need to manually set `PYTHON_EXECUTABLE`, `PYTHON_INCLUDE_DIR`, `PYTHON_LIBRARY` variables:

It should look like this for brew-installed Python (use `-DBUILD_PYTHON3=ON`, `include/pythonX.Xm` and `lib/libpythonX.Xm.dylib` for Python 3):
It should look like this for brew-installed Python:

```sh
mkdir build
Expand All @@ -185,7 +151,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \
-DNUMPY_INCLUDES=/usr/local/Cellar/python/X.X.X/Frameworks/Python.framework/Versions/X.X/lib/pythonX.X/site-packages/numpy/core/include
```

Or for Anaconda (use `-DBUILD_PYTHON3=ON`, `include/pythonX.Xm` and `lib/libpythonX.Xm.dylib` for Python 3):
Or for Anaconda:

```sh
mkdir build
Expand All @@ -198,17 +164,6 @@ cmake .. -DCMAKE_BUILD_TYPE=Release \
-DNUMPY_INCLUDES=~/anacondaX/lib/pythonX.X/site-packages/numpy/core/include
```

To build Julia binding, you first need to install CxxWrap package by running `julia` and using `Pkg.add("CxxWrap")` command (see [MacOS dependencies](#macos_deps)). Then you need to manually set `JlCxx_DIR` variable:

```sh
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DBUILD_JULIA=ON \
-DJlCxx_DIR=~/.julia/vX.X/CxxWrap/deps/usr/lib/cmake/JlCxx/
```


### <a name="windows_build"></a> Windows

Setting up the compilation on Windows is really tedious so using the [precompiled binaries](#windows_bin) is recommended.
Expand All @@ -223,10 +178,9 @@ Run CMake GUI, select ViZDoom root directory and set paths to:
* BOOST_LIBRARYDIR
* PYTHON_INCLUDE_DIR (optional, for Python/Anaconda bindings)
* PYTHON_LIBRARY (optional, for Python/Anaconda bindings)
* NUMPY_INCLUDES (optional, for Python/Anaconda bindings)
* ZDoom dependencies paths

In configuration select BUILD_PYTHON, BUILD_PYTHON3 and BUILD_JAVA options for Python and Java bindings (optional, default OFF).
In configuration select `DBUILD_ENGINE` and `DBUILD_PYTHON` (optional, default ON).

Use generated Visual Studio solution to build all parts of ViZDoom environment.

Expand Down
10 changes: 10 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Changes in 1.1.14

#### Support for Apple Silicon
- Fixed building on Apple Silicon Macbooks.

#### Gym
- OpenAI Gym environment wrappers were updated to the Gym v0.26 API version.

---

## Changes in 1.1.13

#### Releases
Expand Down
2 changes: 1 addition & 1 deletion doc/ConfigFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Each list assignment (**KEY = { VALUES }**)clears values specified for this key
* `DoomConfigPath/doom_config_path`
* `DoomGamePath/doom_game_path`
* `DoomMap/doom_map`
* `DoomScenarioPath/set_doom_scenario_path`
* `DoomScenarioPath/doom_scenario_path`
* `DoomSkill/doom_skill`
* `episodeStartTime/episode_start_time`
* `episodeTimeout/episode_timeout`
Expand Down
2 changes: 1 addition & 1 deletion doc/DoomGame.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
* [isSectorsInfoEnabled](#isSectorsInfoEnabled)
* [setSectorsInfoEnabled](#setSectorsInfoEnabled)
* [isAudioBufferEnabled](#isAudioBufferEnabled)
* [is/setAudioBufferEnabled](#setAudioBufferEnabled)
* [setAudioBufferEnabled](#setAudioBufferEnabled)
* [getAudioSamplingFreq](#getAudioSamplingFreq)
* [setAudioSamplingFreq](#setAudioSamplingFreq)
* [getAudioBufferSize](#getAudioBufferSize)
Expand Down
9 changes: 8 additions & 1 deletion doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ with ViZDoom. You have several options you can try (one of these steps has worke

## How to display ViZDoom's window when running it on WSL (Windows Subsystem for Linux)

GUI apps do not work out-of-the-box on WSL on Windows 10. To make it work you need:
Please note that as running ViZDoom on WSL seems to be working fine, it is not officially supported.

GUI apps do not work out-of-the-box on WSL on Windows 10/11. To make it work, you need:

* Download and install X-Server (VcXsrv) on Windows: https://sourceforge.net/projects/vcxsrv/.
* Start it using Command Prompt (cmd.exe) on Windows: `"C:\Program Files\VcXsrv\vcxsrv.exe" :0 -ac -terminate -lesspointer -multiwindow -clipboard -wgl -dpi auto` (`"C:\Program Files\VcXsrv\vcxsrv.exe"` is default install location).
Expand All @@ -168,3 +170,8 @@ GUI apps do not work out-of-the-box on WSL on Windows 10. To make it work you ne

**Original issue:**
* https://github.com/mwydmuch/ViZDoom/issues/491


## What is a difference between ViZDoom, ZDoom and GZDoom

ViZDoom is based on the last version of ZDoom (2.8.1). ZDoom was discontinued in 2016, and the development switched to GZDoom, which provides a new 3D renderer implemented in OpenGL. ViZDoom, however, sticks to the original 2D software renderer, which is much faster for small resolutions than OpenGL. Because of that, ViZDoom modernized the ZDoom engine by adding support for Apple Silicon and removing old unused parts of the code base (e.g., by removing Assembler parts).
2 changes: 0 additions & 2 deletions doc/Utilities.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Utilities

In Java utilities functions are static methods in DoomGame class.

* [doomTicsToMs](#doomTicsToMs)
* [msToDoomTics](#msToDoomTics)
* [doomTicsToSec](#doomTicsToSec)
Expand Down
Loading

0 comments on commit 53b5eb3

Please sign in to comment.