diff --git a/CMakeLists.txt b/CMakeLists.txt
index b6902dcca..055904ec5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.4)
# Project + versions
#-----------------------------------------------------------------------------------------------------------------------
-project(ViZDoom VERSION 1.2.0)
+project(ViZDoom VERSION 1.2.1)
set(ViZDoom_VERSION_STR ${ViZDoom_VERSION_MAJOR}.${ViZDoom_VERSION_MINOR}.${ViZDoom_VERSION_PATCH})
set(ViZDoom_VERSION_ID ${ViZDoom_VERSION_MAJOR}${ViZDoom_VERSION_MINOR}${ViZDoom_VERSION_PATCH})
diff --git a/docs/README.md b/docs/README.md
index 41c50068c..ce07781c0 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -3,3 +3,9 @@
This directory contains the documentation for ViZDOOm.
For more information about how to contribute to the documentation go to our [CONTRIBUTING.md](https://github.com/Farama-Foundation/Celshast/blob/main/CONTRIBUTING.md)
+
+If you edit the C++ documentation (inside `api_cpp`), you need to run to update other files:
+```
+python scripts/create_python_docs_from_cpp_docs.py
+python scripts/create_python_docstrings_from_cpp_docs.py
+```
diff --git a/docs/api_cpp/configurationFiles.md b/docs/api/configurationFiles.md
similarity index 98%
rename from docs/api_cpp/configurationFiles.md
rename to docs/api/configurationFiles.md
index debf30139..27f3d3ea7 100644
--- a/docs/api_cpp/configurationFiles.md
+++ b/docs/api/configurationFiles.md
@@ -19,7 +19,7 @@ A violation of any of these rules will result in ignoring **only** the line with
### Appending values
Each list assignment (**KEY = { VALUES }**)clears values specified for this key before (in other configuration files or in the code). That is why the **append operator(*KEY += { VALUES })** is available. This way you can more easily combine multiple configuration files and tinker in code.
-### Supported configuration keys:
+### Supported configuration keys:
* `audioBufferEnabled/audio_buffer_enabled`
* `audioBufferSize/audio_buffer_size`
* `audioSamplingRate/audio_samping_rate`
@@ -112,7 +112,6 @@ mode = PLAYER
# Difficulty of gameplay ranging from 1 (baby) to 5 (nightmare)
doom_skill = 5
-
```
Other examples of configuration files can be found in [https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios)
diff --git a/docs/api/cpp.md b/docs/api/cpp.md
new file mode 100644
index 000000000..00d464997
--- /dev/null
+++ b/docs/api/cpp.md
@@ -0,0 +1,18 @@
+# C++ API
+
+ViZDoom is implemented in C++ and can be used as a C++ library. The C++ API is one-to-one with the Python API. The only difference is the use of `camelCase` instead of `snake_case` for method names.
+
+ViZDoom can be built as a static or dynamic library. The header files are located in the `include` directory.
+See [examples/cpp](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/cpp) for examples, including CMake files for building.
+
+
+```{toctree}
+:hidden:
+:caption: C++ API
+
+cpp/doomGame
+cpp/gameState
+cpp/enums
+cpp/exceptions
+cpp/utils
+```
diff --git a/docs/api_cpp/doomGame.md b/docs/api/cpp/doomGame.md
similarity index 99%
rename from docs/api_cpp/doomGame.md
rename to docs/api/cpp/doomGame.md
index 21393e633..96cc0192c 100644
--- a/docs/api_cpp/doomGame.md
+++ b/docs/api/cpp/doomGame.md
@@ -1,6 +1,6 @@
# DoomGame
-DoomGame is the main object of the ViZDoom library, representing a single instance of the Doom game and providing the interface for a single agent/player to interact with the game. The object allows sending actions to the game, getting the game state, etc.
+DoomGame is the main object of the ViZDoom library, representing a single instance of the Doom game and providing the interface for a single agent/player to interact with the game. The object allows sending actions to the game, getting the game state, etc. The declarations of this class and its methods can be found in the `include/ViZDoomGame.h` header file.
Here we document all the methods of the DoomGame class and their corresponding Python bindings implemented as pybind11 module.
diff --git a/docs/api_cpp/enums.md b/docs/api/cpp/enums.md
similarity index 94%
rename from docs/api_cpp/enums.md
rename to docs/api/cpp/enums.md
index 8f094a410..f4a606d33 100644
--- a/docs/api_cpp/enums.md
+++ b/docs/api/cpp/enums.md
@@ -1,5 +1,8 @@
# Enums
+ViZDoom is using few types of enums as parameters for its functions. Below you can find the description of all of them.
+The declarations of all the enums can be found in the `include/ViZDoomTypes.h` header file.
+
## `Mode`
Enum type that defines all supported modes.
@@ -178,11 +181,11 @@ Other from 1 to 60 (global int 1-60) can be accessed as USER1 - USER60 GameVaria
See also:
- [ZDoom Wiki: ACS](http://zdoom.org/wiki/ACS),
-- [`DoomGame: getAvailableGameVariables`](./doomGame.md#getAvailableGameVariables),
-- [`DoomGame: setAvailableGameVariables`](./doomGame.md#setAvailableGameVariables),
-- [`DoomGame: addAvailableGameVariable`](./doomGame.md#addAvailableGameVariable),
-- [`DoomGame: getGameVariable`](./doomGame.md#getGameVariable),
-- [`Utilities: doomFixedToDouble`](Utilities.md#doomFixedToDouble),
+- [`DoomGame: getAvailableGameVariables`](./doomGame.md#getavailablegamevariables),
+- [`DoomGame: setAvailableGameVariables`](./doomGame.md#setavailablegamevariables),
+- [`DoomGame: addAvailableGameVariable`](./doomGame.md#addavailablegamevariable),
+- [`DoomGame: getGameVariable`](./doomGame.md#getgamevariable),
+- [`Utilities: doomFixedToDouble`](utils.md#doomfixedtodouble),
- [examples/python/basic.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/basic.py),
- [examples/python/shaping.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/shaping.py).
@@ -271,3 +274,6 @@ Added in 1.1.9.
- **SR_11025**
- **SR_22050**
- **SR_44100**
+
+See also:
+- [`DoomGame: setAudioSamplingRate`](./doomGame.md#setaudiosamplingrate),
diff --git a/docs/api_cpp/exceptions.md b/docs/api/cpp/exceptions.md
similarity index 89%
rename from docs/api_cpp/exceptions.md
rename to docs/api/cpp/exceptions.md
index 9d877416a..31d87cb5a 100644
--- a/docs/api_cpp/exceptions.md
+++ b/docs/api/cpp/exceptions.md
@@ -1,6 +1,9 @@
# Exceptions
ViZDoom defines several exceptions that can be thrown by its API:
+Most of the exceptions contain more information in "what()" message.
+The declarations of all the enums can be found in the `include/ViZDoomExceptions.h` header file.
+
* `FileDoesNotExistException` - means that file specified as part of a configuration does not exist.
@@ -13,5 +16,3 @@ ViZDoom defines several exceptions that can be thrown by its API:
* `ViZDoomIsNotRunningException` - means that called method cannot be used when ViZDoom instance is not running.
* `ViZDoomUnexpectedExitException` - means that ViZDoom's instance was closed/terminated/killed from the outside.
-
-Most of the exceptions contain more information in "what()" message.
diff --git a/docs/api_cpp/gameState.md b/docs/api/cpp/gameState.md
similarity index 94%
rename from docs/api_cpp/gameState.md
rename to docs/api/cpp/gameState.md
index a584fa99c..20aa25c05 100644
--- a/docs/api_cpp/gameState.md
+++ b/docs/api/cpp/gameState.md
@@ -1,6 +1,7 @@
# GameState
GameState is the main object returned by [`DoomGame: getState`](./doomGame.md#getstate) method.
+The declarations of all the enums can be found in the `include/ViZDoomTypes.h` header file.
## `GameState`
@@ -57,7 +58,10 @@ See also:
- `double / float` **objectVelocityY / object_velocity_y**
- `double / float` **objectVelocityZ / object_velocity_z**
-**objectId / object_id** - unique object ID, if both Labels and Objects information is enabled, this will be the same as **id** in corresponding**Object**.
+
+Description of the object in the labels buffer.
+
+**objectId / object_id** - unique object ID, if both Labels and Objects information is enabled, this will be the same as **id** in corresponding **Object**.
**objectName / object_name** - ingame object name, many different objects can have the same name (e.g. Medikit, Clip, Zombie).
@@ -87,11 +91,12 @@ See also:
- `double / float` **velocityY / velocity_y**
- `double / float` **velocityZ / velocity_z**
+Description of the object present in the game world.
+
**id** - unique object ID.
**name** - ingame object name, many different objects can have the same name (e.g. Medikit, Clip, Zombie).
-Right now `Object` is only available to C++ and Python.
Added in 1.1.8.
See also:
@@ -109,13 +114,14 @@ See also:
- `double / float` **y2**
- `bool / bool` **isBlocking / is_blocking**
+Description of the line that is part of a sector definition.
+
**x1**, **y1** - position of the line's first vertex.
**x2**, **y2** - position of the line's second vertex.
**isBlocking / is_blocking** - is true, if line is a wall that can't be passed.
-Right now `Line` is only available to C++ and Python.
Added in 1.1.8.
See also:
@@ -130,13 +136,14 @@ See also:
- `double / float` **ceilingHeight / ceiling_height**
- `std::vector / list` **lines**
+Description of the sector, part of the map with the same floor and ceiling height.
+
**floorHeight / floor_height** - height of the sector's floor.
**ceilingHeight / ceiling_height** - height of the sector's ceiling.
**lines** - contains list of line segments, that forms sector.
-Right now `Sector` is only available to C++ and Python.
Added in 1.1.8.
See also:
@@ -146,11 +153,6 @@ See also:
---
## `ServerState`
-
-
-ServerState is the main object returned by [`DoomGame: getServerState`](./doomGame.md#getserverstate) method, and it purpose is to get more information about the state of the multi-player game.
-
-
(`C++ type / Python type` **name**)
- `unsigned int / int` **tic**
@@ -162,9 +164,9 @@ ServerState is the main object returned by [`DoomGame: getServerState`](./doomGa
- `unsigned int[] / list` **playersLastActionTic / players_last_action_tic **
- `unsigned int[] / list` **playersLastKillTic / players_last_kill_tic **
-Right now `ServerInfo` is only available to C++ and Python.
-Added in 1.1.6.
+ServerState is the main object returned by [`DoomGame: getServerState`](./doomGame.md#getserverstate) method, and it purpose is to get more information about the state of the multi-player game.
+Added in 1.1.6.
See also:
- [`DoomGame: getServerState`](./doomGame.md#getserverstate),
diff --git a/docs/api_cpp/utils.md b/docs/api/cpp/utils.md
similarity index 96%
rename from docs/api_cpp/utils.md
rename to docs/api/cpp/utils.md
index 27b5bf268..965db509e 100644
--- a/docs/api_cpp/utils.md
+++ b/docs/api/cpp/utils.md
@@ -2,11 +2,11 @@
Here we document the helpers functions that are not part of any object.
They mostly help to deal with conversion of Doom's engine types.
+The declarations of all the enums can be found in the `include/ViZDoomUtils.h` header file.
## Time conversion functions
-
### `doomTicsToMs`
| C++ | `double doomTicsToMs(double tics, unsigned int ticrate = 35)` |
@@ -56,8 +56,6 @@ Calculates the number of seconds that will pass during specified number of tics.
## Doom fixed point conversion functions
-
----
### `doomFixedToDouble`
| C++ | `double doomFixedToDouble(int / double doomFixed)` |
@@ -77,8 +75,6 @@ Python aliases (added in 1.1): `doom_fixed_to_float(doomFixed: int | float) -> f
## Button functions
-
----
### `isBinaryButton`
| C++ | `bool isBinaryButton(Button button)` |
diff --git a/docs/api/python.md b/docs/api/python.md
new file mode 100644
index 000000000..b06c62dfb
--- /dev/null
+++ b/docs/api/python.md
@@ -0,0 +1,19 @@
+# Python API
+
+ViZDoom provides Python bindings for the library. The Python API is one-to-one with the C++ API. The only difference is the use of `snake_case` instead of `camelCase` for method and argument names.
+
+There are many examples of how to use Python API in [examples/python](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python) directory.
+
+
+```{toctree}
+:hidden:
+:caption: Python API
+
+python/doomGame
+python/gameState
+python/enums
+python/utils
+python/exceptions
+python/gymnasium
+python/gym
+```
diff --git a/docs/api_python/doomGame.md b/docs/api/python/doomGame.md
similarity index 97%
rename from docs/api_python/doomGame.md
rename to docs/api/python/doomGame.md
index 3298a3109..d06055cea 100644
--- a/docs/api_python/doomGame.md
+++ b/docs/api/python/doomGame.md
@@ -2,9 +2,6 @@
DoomGame is the main object of the ViZDoom library, representing a single instance of the Doom game and providing the interface for a single agent/player to interact with the game. The object allows sending actions to the game, getting the game state, etc.
-Here we document all the methods of the DoomGame class and their corresponding Python bindings implemented as pybind11 module.
-
-
```{eval-rst}
.. autoclass:: vizdoom.DoomGame
@@ -100,6 +97,11 @@ Here we document all the methods of the DoomGame class and their corresponding P
.. autofunction:: vizdoom.DoomGame.set_episode_start_time
.. autofunction:: vizdoom.DoomGame.get_episode_timeout
.. autofunction:: vizdoom.DoomGame.set_episode_timeout
+```
+
+## Output/rendering setting methods
+
+```{eval-rst}
.. autofunction:: vizdoom.DoomGame.set_screen_resolution
.. autofunction:: vizdoom.DoomGame.get_screen_format
.. autofunction:: vizdoom.DoomGame.set_screen_format
@@ -141,3 +143,4 @@ Here we document all the methods of the DoomGame class and their corresponding P
.. autofunction:: vizdoom.DoomGame.set_audio_sampling_rate
.. autofunction:: vizdoom.DoomGame.get_audio_buffer_size
.. autofunction:: vizdoom.DoomGame.set_audio_buffer_size
+```
diff --git a/docs/api/python/enums.md b/docs/api/python/enums.md
new file mode 100644
index 000000000..760f2d5d0
--- /dev/null
+++ b/docs/api/python/enums.md
@@ -0,0 +1,174 @@
+# Enums
+
+ViZDoom is using few types of enums as parameters for its functions.
+
+```{eval-rst}
+.. autoclass:: vizdoom.Mode
+```
+
+In **PLAYER** and **ASYNC_PLAYER** modes, the agent controls ingame character.
+
+In **SPECTATOR** and **ASYNC_SPECTATOR** modes, ingame character should be controlled by the human and the agent gets information about the human action.
+
+In **PLAYER** and **SPECTATOR** modes, the game waits for agent action or permission to continue.
+
+In **ASYNC** modes the game progress with constant speed (default 35 tics per second, this can be set) without waiting for the agent actions.
+
+All modes can be used in singleplayer and multiplayer.
+
+See also:
+- [`DoomGame.get_mode`](./doomGame.md#vizdoom.DoomGame.get_mode),
+- [`DoomGame.set_mode`](./doomGame.md#vizdoom.DoomGame.set_mode),
+- [`DoomGame.get_ticrate`](./doomGame.md#vizdoom.DoomGame.get_ticrate),
+- [`DoomGame.set_ticrate`](./doomGame.md#vizdoom.DoomGame.set_ticrate).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.ScreenFormat
+```
+
+Enum type that defines all supported **screenBuffer** and **automapBuffer** formats.
+
+- **CRCGCB** - 3 channels of 8-bit values in RGB order
+- **RGB24** - channel of RGB values stored in 24 bits, where R value is stored in the oldest 8 bits
+- **RGBA32** - channel of RGBA values stored in 32 bits, where R value is stored in the oldest 8 bits
+- **ARGB32** - channel of ARGB values stored in 32 bits, where A value is stored in the oldest 8 bits
+- **CBCGCR** - 3 channels of 8-bit values in BGR order
+- **BGR24** - channel of BGR values stored in 24 bits, where B value is stored in the oldest 8 bits
+- **BGRA32** - channel of BGRA values stored in 32 bits, where B value is stored in the oldest 8 bits
+- **ABGR32** - channel of ABGR values stored in 32 bits, where A value is stored in the oldest 8 bits
+- **GRAY8** - 8-bit gray channel
+- **DOOM_256_COLORS8** - 8-bit channel with Doom palette values
+
+
+In **CRCGCB** and **CBCGCR** format **screenBuffer** and **automapBuffer** store all red 8-bit values then all green values and then all blue values, each channel is considered separately. As matrices they have [3, y, x] shape.
+
+In **RGB24** and **BGR24** format **screenBuffer** and **automapBuffer** store 24 bit RGB triples. As matrices they have [y, x, 3] shape.
+
+In **RGBA32**, **ARGB32**, **BGRA32** and **ABGR32** format **screenBuffer** and **automapBuffer** store 32 bit sets of RBG + alpha values. As matrices they have [y, x, 4] shape.
+
+In **GRAY8** and **DOOM_256_COLORS8** format **screenBuffer** and **automapBuffer** store single 8 bit values. As matrices they have [y, x] shape.
+
+**depthBuffer** and **lablesBuffer** always store single 8-bit values, so they always have [y, x] shape.
+
+See also:
+- [`DoomGame.get_screen_format`](./doomGame.md#vizdoom.DoomGame.get_screen_format),
+- [`DoomGame.set_screen_format`](./doomGame.md#vizdoom.DoomGame.set_screen_format),
+- [examples/python/buffers.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/buffers.py).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.ScreenResolution
+```
+
+Enum type that defines all supported resolutions - shapes of **screenBuffer**, **depthBuffer**, **labelsBuffer** and **automapBuffer** in **State**.
+
+See also:
+- [`DoomGame.set_screen_resolution`](./doomGame.md#vizdoom.DoomGame.set_screen_resolution),
+- [`DoomGame.get_screen_width`](./doomGame.md#vizdoom.DoomGame.get_screen_width),
+- [`DoomGame.get_screen_height`](./doomGame.md#vizdoom.DoomGame.get_screen_height).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.AutomapMode
+```
+
+Enum type that defines all **automapBuffer** modes.
+
+- **NORMAL** - Only level architecture the player has seen is shown.
+- **WHOLE** - All architecture is shown, regardless of whether or not the player has seen it.
+- **OBJECTS** - In addition to the previous, shows all things in the map as arrows pointing in the direction they are facing.
+- **OBJECTS_WITH_SIZE** - In addition to the previous, all things are wrapped in a box showing their size.
+
+See also:
+- [`DoomGame.set_automap_mode`](./doomGame.md#vizdoom.DoomGame.set_automap_mode),
+- [examples/python/buffers.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/buffers.py).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.GameVariable
+```
+
+Enum type that defines all variables that can be obtained from the game. Below we describe the meaning of each variable.
+
+- **KILLCOUNT** - Counts the number of monsters killed during the current episode. ~Killing other players/bots do not count towards this.~ From 1.1.5 killing other players/bots counts towards this.
+- **ITEMCOUNT** - Counts the number of picked up items during the current episode.
+- **SECRETCOUNT** - Counts the number of secret location/objects discovered during the current episode.
+- **FRAGCOUNT** - Counts the number of players/bots killed, minus the number of committed suicides. Useful only in multiplayer mode.
+- **DEATHCOUNT** - Counts the number of players deaths during the current episode. Useful only in multiplayer mode.
+- **HITCOUNT** - Counts number of hit monsters/players/bots during the current episode. Added in 1.1.5.
+- **HITS_TAKEN** - Counts number of hits taken by the player during the current episode. Added in 1.1.5.
+- **DAMAGECOUNT** - Counts number of damage dealt to monsters/players/bots during the current episode. Added in 1.1.5.
+- **DAMAGE_TAKEN** - Counts number of damage taken by the player during the current episode. Added in 1.1.5.
+- **HEALTH** - Can be higher then 100!
+- **ARMOR** - Can be higher then 100!
+- **DEAD** - True if the player is dead.
+- **ON_GROUND** - True if the player is on the ground (not in the air).
+- **ATTACK_READY** - True if the attack can be performed.
+- **ALTATTACK_READY** - True if the altattack can be performed.
+- **SELECTED_WEAPON** - Selected weapon's number.
+- **SELECTED_WEAPON_AMMO** - Ammo for selected weapon.
+- **AMMO0** - **AMMO9** - Number of ammo for weapon in N slot.
+- **WEAPON0** - **WEAPON9** - Number of weapons in N slot.
+- **POSITION_X, POSITION_Y, POSITION_Z** - Position of the player, not available if `viz_nocheat` is enabled.
+- **ANGLE, PITCH, ROLL** - Orientation of the player, not available if `viz_nocheat` is enabled.
+- **VIEW_HEIGHT** - View high of the player, not available if `viz_nocheat` is enabled. Position of the camera in Z axis is equal to **POSITION_Z** + **VIEW_HEIGHT**. Added in 1.1.7.
+- **VELOCITY_X, VELOCITY_Y, VELOCITY_Z** - Velocity of the player, not available if `viz_nocheat` is enabled.
+- **CAMERA_POSITION_X, CAMERA_POSITION_Y, CAMERA_POSITION_Z** - Position of the camera, not available if `viz_nocheat` is enabled. Added in 1.1.7.
+- **CAMERA_ANGLE, CAMERA_PITCH, CAMERA_ROLL** - Orientation of the camera, not available if `viz_nocheat` is enabled. Added in 1.1.7.
+- **CAMERA_FOV** - Field of view in degrees, not available if `viz_nocheat` is enabled. Added in 1.1.7.
+- **PLAYER_NUMBER** - Player's number in multiplayer game.
+- **PLAYER_COUNT** - Number of players in multiplayer game.
+- **PLAYER1_FRAGCOUNT** - **PLAYER16_FRAGCOUNT** - Number of N player's frags
+- **USER1** - **USER60** - user defined variables. ACS global int variables can be accessed as USER GameVariables.
+global int 0 is reserved for reward and is always threaded as Doom's fixed point numeral.
+Other from 1 to 60 (global int 1-60) can be accessed as USER1 - USER60 GameVariables.
+
+See also:
+- [ZDoom Wiki: ACS](http://zdoom.org/wiki/ACS),
+- [`DoomGame.get_available_game_variables`](./doomGame.md#vizdoom.DoomGame.get_available_game_variables),
+- [`DoomGame.set_available_game_variables`](./doomGame.md#vizdoom.DoomGame.set_available_game_variables),
+- [`DoomGame.add_available_game_variable`](./doomGame.md#vizdoom.DoomGame.add_available_game_variable),
+- [`DoomGame.get_game_variable`](./doomGame.md#vizdoom.DoomGame.get_game_variable),
+- [`doomFixedToDouble`](utils.md#doomfixedtodouble),
+- [examples/python/basic.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/basic.py),
+- [examples/python/shaping.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/shaping.py).
+
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.Button
+```
+
+Enum type that defines all buttons that can be "pressed" by the agent. They can be divided into two categories:
+
+1. Delta buttons whose value defines the speed of movement.
+A positive value indicates movement in the first specified direction and a negative value in the second direction.
+For example: value 10 for MOVE_LEFT_RIGHT_DELTA means slow movement to the right and -100 means fast movement to the left.
+- **LOOK_UP_DOWN_DELTA, TURN_LEFT_RIGHT_DELTA** - where value correspond to degrees.
+- **MOVE_FORWARD_BACKWARD_DELTA, MOVE_LEFT_RIGHT_DELTA, MOVE_UP_DOWN_DELTA** - where values correspond to Doom Map unit (see Doom Wiki if you want to know how it translates into real life units).
+
+2. Binary buttons
+Binary buttons have only 2 states "not pressed" if value 0 and "pressed" if value other then 0. They are all the other buttons not listed above as delta buttons.
+
+See also:
+- [Doom Wiki: Map unit](https://doomwiki.org/wiki/Map_unit),
+- [`DoomGame.get_available_buttons`](./doomGame.md#vizdoom.DoomGame.get_available_buttons),
+- [`DoomGame.set_available_buttons`](./doomGame.md#vizdoom.DoomGame.set_available_buttons),
+- [`DoomGame.add_available_button`](./doomGame.md#vizdoom.DoomGame.add_available_button),
+- [`DoomGame.set_button_max_value`](./doomGame.md#vizdoom.DoomGame.set_button_max_value),
+- [`DoomGame.get_button_max_value`](./doomGame.md#vizdoom.DoomGame.get_button_max_value),
+- [examples/python/basic.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/basic.py),
+- [examples/python/delta_buttons.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/delta_buttons.py),
+- [GitHub issue: Angle changes by executing certain commands](https://github.com/Farama-Foundation/ViZDoom/issues/182).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.SamplingRate
+```
+
+Enum type that defines all supported sampling rates for **audioBuffer** in **State**.
+Added in 1.1.9.
+
+See also:
+- [`DoomGame.set_audio_sampling_rate`](./doomGame.md#set_audio_sampling_rate),
diff --git a/docs/api/python/exceptions.md b/docs/api/python/exceptions.md
new file mode 100644
index 000000000..92843dc43
--- /dev/null
+++ b/docs/api/python/exceptions.md
@@ -0,0 +1,45 @@
+# Exceptions
+
+ViZDoom defines several exceptions that can be thrown by its API.
+Most of the exceptions contain more information in the exception's message.
+
+```{eval-rst}
+.. autoexception:: vizdoom.FileDoesNotExistException
+```
+Means that file specified as part of a configuration does not exist.
+
+```{eval-rst}
+.. autoexception:: vizdoom.MessageQueueException
+```
+
+Means that communication with ViZDoom's instance failed. Usually, means a problem with permissions or system configuration.
+
+```{eval-rst}
+.. autoexception:: vizdoom.SharedMemoryException
+```
+
+Means that allocation/reading of shared memory failed. Usually, means a problem with permissions or system configuration.
+
+```{eval-rst}
+.. autoexception:: vizdoom.SignalException
+```
+
+Means that a signal was cached by ViZDoom's instance.
+
+```{eval-rst}
+.. autoexception:: vizdoom.ViZDoomErrorException
+```
+
+Means that an error in the ViZDoom engine occurred.
+
+```{eval-rst}
+.. autoexception:: vizdoom.ViZDoomIsNotRunningException
+```
+
+Means that called method cannot be used when ViZDoom instance is not running.
+
+```{eval-rst}
+.. autoexception:: vizdoom.ViZDoomUnexpectedExitException
+```
+
+Means that ViZDoom's instance was closed/terminated/killed from the outside.
diff --git a/docs/api/python/gameState.md b/docs/api/python/gameState.md
new file mode 100644
index 000000000..ec57ffd98
--- /dev/null
+++ b/docs/api/python/gameState.md
@@ -0,0 +1,108 @@
+# GameState
+
+```{eval-rst}
+.. autoclass:: vizdoom.GameState
+ :members:
+ :undoc-members:
+```
+
+**number** - number of the state in the episode.
+**tic** - ingame time, 1 tic is 1/35 of second in the game world. Added in 1.1.1.
+
+See also:
+- [`DoomGame.get_state`](./doomGame.md#vizdoom.DoomGame.get_state),
+- [examples/python/basic.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/basic.py),
+- [examples/python/buffers.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/buffers.py).
+- [examples/python/audio_buffer.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/audio_buffer.py).
+
+
+## Data types used in GameState
+
+```{eval-rst}
+.. autoclass:: vizdoom.Label
+ :members:
+ :undoc-members:
+```
+
+**object_id** - unique object ID, if both Labels and Objects information is enabled, this will be the same as **id** in corresponding **Object**.
+
+**object_name** - ingame object name, many different objects can have the same name (e.g. Medikit, Clip, Zombie).
+
+**value** - value that represents this particular object in **labels_buffer**.
+
+**x**, **y**, **width**, **height** - describes bounding box of this particular object in **labels_buffer**. Added in 1.1.5.
+
+
+See also:
+- [`DoomGame.set_labels_buffer_enabled`](./doomGame.md#vizdoom.DoomGame.set_labels_buffer_enabled),
+- [examples/python/objects_and_sectors.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/labels_buffer.py).
+
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.Object
+ :members:
+ :undoc-members:
+```
+
+**id** - unique object ID.
+
+**name** - ingame object name, many different objects can have the same name (e.g. Medikit, Clip, Zombie).
+
+Added in 1.1.8.
+
+See also:
+- [`DoomGame.set_objects_info_enabled`](./doomGame.md#vizdoom.DoomGame.set_sectors_info_enabled),
+- [examples/python/objects_and_sectors.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/objects_and_sectors.py).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.Line
+ :members:
+ :undoc-members:
+```
+
+**x1**, **y1** - position of the line's first vertex.
+
+**x2**, **y2** - position of the line's second vertex.
+
+**is_blocking** - is true, if line is a wall that can't be passed.
+
+Added in 1.1.8.
+
+See also:
+- [examples/python/objects_and_sectors.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/objects_and_sectors.py).
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.Sector
+ :members:
+ :undoc-members:
+```
+
+**floor_height** - height of the sector's floor.
+
+**ceiling_height** - height of the sector's ceiling.
+
+**lines** - contains list of line segments, that forms sector.
+
+Added in 1.1.8.
+
+See also:
+- [`DoomGame.set_sectors_info_enabled`](./doomGame.md#vizdoom.DoomGame.set_sectors_info_enabled),
+- [examples/python/objects_and_sectors.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/objects_and_sectors.py).
+
+
+
+```{eval-rst}
+.. autoclass:: vizdoom.ServerState
+ :members:
+ :undoc-members:
+```
+
+ServerState is the main object returned by [`DoomGame.get_server_state`](./doomGame.md#vizdoom.DoomGame.get_server_state) method, and it purpose is to get more information about the state of the multi-player game.
+
+Added in 1.1.6.
+
+See also:
+- [`DoomGame.get_server_state`](./doomGame.md#vizdoom.DoomGame.get_server_state),
diff --git a/docs/api/python/gym.md b/docs/api/python/gym.md
new file mode 100644
index 000000000..0ca92a1b3
--- /dev/null
+++ b/docs/api/python/gym.md
@@ -0,0 +1,8 @@
+# OpenAI Gym Env
+
+> Gym is deprecated in favor of Gymnasium and these wrappers will be removed in the future.
+
+```{eval-rst}
+.. autoclass:: vizdoom.gym_wrapper.base_gym_env.VizdoomEnv
+ :members:
+```
diff --git a/docs/api/python/gymnasium.md b/docs/api/python/gymnasium.md
new file mode 100644
index 000000000..59034bbac
--- /dev/null
+++ b/docs/api/python/gymnasium.md
@@ -0,0 +1,6 @@
+# Gymnasium Env
+
+```{eval-rst}
+.. autoclass:: vizdoom.gymnasium_wrapper.base_gymnasium_env.VizdoomEnv
+ :members:
+```
diff --git a/docs/api_python/utils.md b/docs/api/python/utils.md
similarity index 99%
rename from docs/api_python/utils.md
rename to docs/api/python/utils.md
index b36354c4c..11994a48e 100644
--- a/docs/api_python/utils.md
+++ b/docs/api/python/utils.md
@@ -4,8 +4,6 @@ Here we document the helpers functions that are not part of any object.
They mostly help to deal with conversion of Doom's engine types.
-
-
## Time conversion functions
```{eval-rst}
@@ -26,3 +24,4 @@ They mostly help to deal with conversion of Doom's engine types.
```{eval-rst}
.. autofunction:: vizdoom.is_binary_button
.. autofunction:: vizdoom.is_delta_button
+```
diff --git a/docs/api_python/enums.md b/docs/api_python/enums.md
deleted file mode 100644
index d1e19d0ad..000000000
--- a/docs/api_python/enums.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Enums
-
-This page is under construction.
diff --git a/docs/api_python/gameState.md b/docs/api_python/gameState.md
deleted file mode 100644
index 8ce4a5e2f..000000000
--- a/docs/api_python/gameState.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# GameState
-
-This page is under construction.
diff --git a/docs/api_python/gymnasium.md b/docs/api_python/gymnasium.md
deleted file mode 100644
index 605e42b71..000000000
--- a/docs/api_python/gymnasium.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Gymnasium
-
-This page is under construction.
diff --git a/docs/conf.py b/docs/conf.py
index 9255186c9..abc55b78d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -18,7 +18,7 @@
import os
from typing import Any, Dict # noqa
-import vizdoom # noqa
+from vizdoom import * # noqa
project = "ViZDoom"
@@ -65,6 +65,26 @@
autoclass_content = "both"
autodoc_preserve_defaults = True
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+add_module_names = False
+
+
+# Shorten C++ module signatures
+def strip_signatures(app, what, name, obj, options, signature, return_annotation):
+ if signature is not None:
+ signature = signature.replace(".vizdoom.", ".")
+
+ if return_annotation is not None:
+ return_annotation = return_annotation.replace(".vizdoom.", ".")
+
+ return signature, return_annotation
+
+
+def setup(app):
+ app.connect("autodoc-process-signature", strip_signatures)
+
+
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
diff --git a/docs/environments/creatingCustom.md b/docs/environments/creatingCustom.md
index a9d7ed500..f7196614d 100644
--- a/docs/environments/creatingCustom.md
+++ b/docs/environments/creatingCustom.md
@@ -1,4 +1,104 @@
# Creating a custom environment
-This page is under development.
-For now you can check the original ViZDoom tutorial [here](https://vizdoom.cs.put.edu.pl/tutorial) that covers this topic.
+ViZDoom allows using of custom scenarios/environments that can be easily prepared using modern Doom map editors like [SLADE](http://slade.mancubus.net/index.php?page=downloads) (available for Linux, MacOS, and Windows) or [DoomBuilder](http://www.doombuilder.com/index.php?p=downloads) (a bit better editor, but only available for Windows), that we recommend using. These editors allow designing a map used by the environment as well as programming the custom logic and rewards using ACS scripting language. In addition to a map created in one of the editors that are saved to a .wad file, ViZDoom uses .cfg config files that store additional information about the environment. Such .wad and .cfg together define a custom environment that can be used with ViZDoom. The following will guide you through the process of creating a custom environment.
+
+
+## Limitations and possibilities
+
+Before we start explaining the process of creating custom environments, one question you might ask is what kind of environments can be created using the old Doom engine. The following list summarizes the most important limitations and possibilities for creating the environments for ViZDoom:
+
+- **3D is limited:** ViZDoom engine does not support full 3D maps. As in the original Doom, the map is, in fact, a 2D map with additional information about floor and ceiling height. This means that some 3D structures, like bridges or multi-floor buildings, are impossible in ViZDoom. However, ViZDoom supports 3D movement like jumping, crouching, swimming, or flying, which were not possible in original Doom.
+- **Map editors are easy to use:** Because of 3D limitations, the Doom-level editors (like mentioned SLADE or DoomBuilder) are actually much simpler than editors for later full 3D engines since they are based on drawing a map from a top-down view. Because of that, they are much easier to use, and everyone is able to create new maps right away.
+- **Scripting is powerful:** ViZDoom environments are not limited to particular tasks, as ViZDoom supports ACS scripting language, which was created for later revisions of the Doom engine.
+It has a simple C-like syntax and is very powerful. It allows to create of custom game rules and rewards. It has a large number of functions that allow to modify/extend the game logic in many ways. ZDoom ACS documentation (https://zdoom.org/wiki/ACS) is generally well-written and complete, making it easy to find the right function for the task.
+Due to the engine's architecture, the only area that ACS is a bit lacking is the possibility of modifying map geometry. Simple modifications, like changing the height of some part of the level to create elevators or doors, are possible, but there are not many more options. Using those, it is possible, for example, to create a randomized maze, but something more complex might be tricky or impossible.
+- **Basic functionality provided by the library:** To simplify the creation of environments, some simple functionalities are also embedded into the library. This way, they don't need to be implemented in ACS every single time but can be configured in a config file. These include:
+ - possibility to define actions space
+ - possibility to define what is included in the observation (types of buffers, additional variables, etc.)
+ - living rewards and death rewards
+ - limited time/truncation
+- **Lack of advanced physics:** ViZDoom engine is obviously based on old technology, and it's limited. It does not support advanced physics, so environments where the aim is to move objects, build structures, etc., are not possible.
+- **Support for multiplayer**: ViZDoom supports multiplayer for up to 16 players. Beyond standard multiplayer mods. ACS can be used to create custom multiplayer scenarios, which can be cooperative or adversarial.
+
+
+## Step 1: Creating a custom map
+
+To create a custom scenario (.wad file), you need to use a dedicated editor. [SLADE](http://slade.mancubus.net/index.php?page=downloads) (available for Linux, MacOS, and Windows) or [DoomBuilder](http://www.doombuilder.com/index.php?p=downloads) (a bit better editor, but only available for Windows), are software that we recommend using for this task.
+
+When creating a new map, select UDMF format for maps and ZDBPS, which is a node builder for ZDoom. You should not have any problems with creating a map using the editor, it is simple, and you can find a lot of tutorials on the internet.
+
+You can add some custom ACS scripts to your map. This ACS script allows to add implement a rewarding mechanism.
+To do that, you need to employ the global variable 0 like this:
+
+```{code-block} C
+global int 0:reward;
+...
+script 1(void)
+{
+ ...
+ reward += 100.0;
+}
+...
+```
+
+The global variable 0 will be used by ViZDoom to get the reward value.
+
+Please note that in ACS 1.0 and 1 are not the same. The first one is the fixed point number stored in int, and the second one is an ordinary int. Watch out for what is expected by the functions you use cause using the wrong format can result in rubbish.
+ViZDoom treats the reward as a fixed point numeral, so you always need to use decimal points in ACS scripts.
+
+
+## Step 2: Creating a custom config file
+
+After creating a map, it is a good idea to create an accompanying config file, that allows to easily defined action space, available information in a state/observation, additional rewards, etc. The config file is a simple text file in ini-like format that can be created using any text editor. The config files are documented under [api/configurationFiles.md](api/configurationFiles.md).
+
+The following is an example of a config file that can be used with the map created in the previous step:
+
+```{code-block} ini
+doom_scenario_path = mywad.wad
+doom_map = map01 # map in the wad file that will be used (wad can contain more than one map)
+
+living_reward = -1 # add -1 reward for each tic (action)
+episode_start_time = 14 # make episodes start after 14 tics (after unholstering the gun)
+episode_timeout = 300 # make episodes finish after 300 actions (tics)
+
+available_buttons = { # limit action space to only three buttons
+ MOVE_LEFT
+ MOVE_RIGHT
+ ATTACK
+}
+
+available_game_variables = { # make information about ammo available in the state
+ AMMO2
+ AMMO3
+}
+
+depth_buffer = true # add depth buffer to the state
+```
+
+
+## Step 3: Loading/using a custom environment/scenario
+
+The easiest way to use a custom scenario in the original ViZDoom API is to load the config file using a dedicated method:
+
+```{code-block} python
+game = vzd.DoomGame()
+game.load_config("")
+```
+
+It can also be registered as a Gymnasium environment using the following method:
+
+```{code-block} python
+from gymnasium.envs.registration import register
+
+register(
+ id="",
+ entry_point="vizdoom.gymnasium_wrapper.base_gymnasium_env:VizdoomEnv",
+ kwargs={"scenario_file": ""},
+)
+```
+
+And then used as any other Gymnasium environment:
+
+```{code-block} python
+env = gymnasium.make("")
+```
diff --git a/docs/index.md b/docs/index.md
index e388a393e..d1b633398 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -40,7 +40,7 @@ There is also the original ViZDoom API:
```{code-block} python
import vizdoom as vzd
-game = DoomGame()
+game = vzd.DoomGame()
game.load_config(os.path.join(vzd.scenarios_path, "deadly_corridor.cfg"))
game.init()
for _ in range(1000):
@@ -61,30 +61,16 @@ game.close()
introduction/pythonQuickstart
introduction/building
-introduction/wrappers
+introduction/apisAndWrappers
```
```{toctree}
:hidden:
-:caption: Python API
+:caption: API
-api_python/gymnasium
-api_python/doomGame
-api_python/gameState
-api_python/enums
-api_python/utils
-```
-
-```{toctree}
-:hidden:
-:caption: C++ API
-
-api_cpp/doomGame
-api_cpp/gameState
-api_cpp/enums
-api_cpp/configurationFiles
-api_cpp/exceptions
-api_cpp/utils
+api/python
+api/cpp
+api/configurationFiles
```
```{toctree}
@@ -101,6 +87,7 @@ environments/creatingCustom
faq/index
citation/index
+Original website
```
```{toctree}
diff --git a/docs/introduction/apisAndWrappers.md b/docs/introduction/apisAndWrappers.md
new file mode 100644
index 000000000..bec2456e8
--- /dev/null
+++ b/docs/introduction/apisAndWrappers.md
@@ -0,0 +1,61 @@
+# APIs and wrappers
+
+ViZDoom consists of a few APIs: C++ API, Python API that is a wrapper around C++ API, and Gymnasium/Gym wrappers that wrap around Python API to allow to use ViZDoom environments as Gymnasium/Gym environments.
+
+Because ViZDoom was created before the first release of OpenAI Gym, it uses a bit different nomenclature in its API than Gym/Gymnasium:
+- **environments = scenarios** - in the original ViZDoom API, environments are called scenarios,
+- **observations = states** - in the original ViZDoom API, observations are called states,
+- **steps = tics** - in the original ViZDoom API, steps are called tics, that's in the original Doom engine. The tic is a single logic update of the game that is 1/35 of a second.
+
+
+## C++ API
+
+ViZDoom is implemented in C++ and can be used as a C++ library. The C++ API is one-to-one with the Python API. The only difference is the use of `camelCase` instead of `snake_case` for method names.
+
+ViZDoom can be built as a static or dynamic library. The header files are located in the `include` directory.
+See [examples/cpp](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/cpp) for examples, including CMake files for building.
+
+
+## Python API
+
+ViZDoom provides Python bindings for the library. The Python API is one-to-one with the C++ API. The only difference is the use of `snake_case` instead of `camelCase` for method and argument names.
+
+There are many examples of how to use Python API in [examples/python](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python) directory.
+
+
+## Gymnasium wrappers
+
+Installing ViZDoom with `pip install vizdoom` will include
+Gymnasium wrappers to interact with ViZDoom over [Gymnasium API](https://gymnasium.farama.org/).
+
+These wrappers are under `gymnasium_wrappers`, containing the basic environment and
+few example environments based on the built-in scenarios. This environment
+simply initializes ViZDoom with the settings from the scenario config files
+and implements the necessary API to function as a Gymnasium API.
+
+See following examples for use:
+- [examples/python/gymnasium_wrapper.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/gymnasium_wrapper.py) for basic usage
+- [examples/python/learning_stable_baselines.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/learning_stable_baselines.py) for example training with [stable-baselines3](https://github.com/DLR-RM/stable-baselines3/) (Update - Currently facing issues, to be fixed)
+
+
+## OpenAI Gym wrappers
+
+> Gym is deprecated in favor of Gymnasium and these wrappers will be removed in the future.
+
+Installing ViZDoom with `pip install vizdoom[gym]` will include
+Gym wrappers to interact with ViZDoom over Gym API.
+
+These wrappers are under `gym_wrappers`, containing the basic environment and
+few example environments based on the built-in scenarios. This environment
+simply initializes ViZDoom with the settings from the scenario config files
+and implements the necessary API to function as a Gym API.
+
+See following examples for use:
+- [examples/python/gym_wrapper.py](https://github.com/Farama-Foundation/ViZDoom/tree/master/examples/python/gym_wrapper.py) for basic usage
+
+
+## Julia, Lua, and Java APIs
+
+> Julia, Lua, and Java bindings are no longer maintained.
+
+Julia, Lua, and Java can be found in [julia](https://github.com/Farama-Foundation/ViZDoom/tree/julia) and [java&lua](https://github.com/Farama-Foundation/ViZDoom/tree/java%26lua) branches for manual bilding.
diff --git a/docs/introduction/wrappers.md b/docs/introduction/wrappers.md
deleted file mode 100644
index 3c5e3e95e..000000000
--- a/docs/introduction/wrappers.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# Wrapper
-
-## Gymnasium wrappers
-
-Installing ViZDoom with `pip install vizdoom` will include
-Gymnasium wrappers to interact with ViZDoom over [Gymnasium API](https://gymnasium.farama.org/).
-
-These wrappers are under `gymnasium_wrappers`, containing the basic environment and
-few example environments based on the built-in scenarios. This environment
-simply initializes ViZDoom with the settings from the scenario config files
-and implements the necessary API to function as a Gymnasium API.
-
-See following examples for use:
- - `examples/python/gymnasium_wrapper.py` for basic usage
- - `examples/python/learning_stable_baselines.py` for example training with [stable-baselines3](https://github.com/DLR-RM/stable-baselines3/) (Update - Currently facing issues, to be fixed)
-
-
-## OpenAI Gym wrappers
-
-Installing ViZDoom with `pip install vizdoom[gym]` will include
-Gym wrappers to interact with ViZDoom over Gym API. Note that Gym is deprecated in favour of Gymnasium and these wrappers will be removed in the future.
-
-These wrappers are under `gym_wrappers`, containing the basic environment and
-few example environments based on the built-in scenarios. This environment
-simply initializes ViZDoom with the settings from the scenario config files
-and implements the necessary API to function as a Gym API.
-
-See following examples for use:
- - `examples/python/gym_wrapper.py` for basic usage
diff --git a/include/ViZDoomGame.h b/include/ViZDoomGame.h
index d36f8f419..f1e1d343d 100644
--- a/include/ViZDoomGame.h
+++ b/include/ViZDoomGame.h
@@ -93,9 +93,9 @@ namespace vizdoom {
/*------------------------------------------------------------------------------------------------------------*/
std::vector getAvailableGameVariables();
- void setAvailableGameVariables(std::vector gameVariables);
+ void setAvailableGameVariables(std::vector variables);
- void addAvailableGameVariable(GameVariable var);
+ void addAvailableGameVariable(GameVariable variable);
void clearAvailableGameVariables();
size_t getAvailableGameVariablesSize();
double getGameVariable(GameVariable variable);
diff --git a/scripts/create_python_docs_from_cpp_docs.py b/scripts/create_python_docs_from_cpp_docs.py
index 38173f539..3e04a69e1 100755
--- a/scripts/create_python_docs_from_cpp_docs.py
+++ b/scripts/create_python_docs_from_cpp_docs.py
@@ -5,8 +5,8 @@
FILES_TO_PARSE = [
{
- "input_filepath": "docs/api_cpp/doomGame.md",
- "output_filepath": "docs/api_python/doomGame.md",
+ "input_filepath": "docs/api/cpp/doomGame.md",
+ "output_filepath": "docs/api/python/doomGame.md",
"submodule": "DoomGame.",
"append_to_header": """
```{eval-rst}
@@ -15,12 +15,12 @@
""",
},
{
- "input_filepath": "docs/api_cpp/utils.md",
- "output_filepath": "docs/api_python/utils.md",
+ "input_filepath": "docs/api/cpp/utils.md",
+ "output_filepath": "docs/api/python/utils.md",
"submodule": "",
},
]
-SECTION_REGEX = r"^##+ *([a-zA-Z ]+) *$"
+SECTION_REGEX = r"^##+ *([a-zA-Z/-:, ]+) *$"
FUNCTION_REGEX = r"^###+ *`([a-zA-Z]+)` *$"
@@ -63,3 +63,5 @@
output_file.write(
f".. autofunction:: vizdoom.{fp['submodule']}{function_name}\n"
)
+
+ output_file.write("```\n")
diff --git a/scripts/create_python_docstrings_from_cpp_docs.py b/scripts/create_python_docstrings_from_cpp_docs.py
index 74b989025..4df563354 100755
--- a/scripts/create_python_docstrings_from_cpp_docs.py
+++ b/scripts/create_python_docstrings_from_cpp_docs.py
@@ -4,14 +4,16 @@
FILES_TO_PARSE = [
- {"filepath": "docs/api_cpp/doomGame.md", "namespace": "DoomGamePython"},
- {"filepath": "docs/api_cpp/utils.md"},
+ {"filepath": "docs/api/cpp/doomGame.md", "namespace": "DoomGamePython"},
+ {"filepath": "docs/api/cpp/utils.md"},
]
-OUTPUT_FILE = "src/lib_python/ViZDoomDocstrings.h"
+OUTPUT_FILE = "src/lib_python/ViZDoomMethodsDocstrings.h"
RAW_STRING_ESCAPE_SEQ = "DOCSTRING"
FUNCTION_HEADER_REGEX = r"^##+ *`([a-zA-Z]+)` *$"
TO_REPLACE = [
- r"\[([`a-zA-Z]+)\]\(.*\)", # Links
+ (r"\[([`a-zA-Z]+)\]\(.*\)", r"\1"), # Links
+ ("true", "True"), # cpp -> python bool
+ ("false", "False"), # cpp -> python bool
]
LINES_TO_IGNORE_REGEXES = [
r"---", # Lines
@@ -32,14 +34,13 @@
if __name__ == "__main__":
with open(OUTPUT_FILE, "w") as output_file:
output_file.write(
- """
-/*
+ """/*
This file is autogenerated by scripts/create_python_docstrings_from_cpp_docs.py
- Do not edit it manually. Edit the Markdown files under docs/api_cpp/ directory instead and regenerate it.
+ Do not edit it manually. Edit the Markdown files under docs/api/cpp/ directory instead and regenerate it.
*/
-#ifndef __VIZDOOM_DOCSTRINGS_H__
-#define __VIZDOOM_DOCSTRINGS_H__
+#ifndef __VIZDOOM_METHODS_DOCSTRINGS_H__
+#define __VIZDOOM_METHODS_DOCSTRINGS_H__
namespace vizdoom {
namespace docstrings {
@@ -76,7 +77,7 @@
# Filter out some lines
if not any(re.match(r, line) for r in LINES_TO_IGNORE_REGEXES):
for r in TO_REPLACE:
- line = re.sub(r, r"\1", line)
+ line = re.sub(r[0], r[1], line)
next_docstring += line
if started:
diff --git a/src/lib/ViZDoomGame.cpp b/src/lib/ViZDoomGame.cpp
index 4e5beddec..8ff421e4f 100644
--- a/src/lib/ViZDoomGame.cpp
+++ b/src/lib/ViZDoomGame.cpp
@@ -398,16 +398,16 @@ namespace vizdoom {
return this->availableGameVariables;
}
- void DoomGame::setAvailableGameVariables(std::vector gameVariables){
+ void DoomGame::setAvailableGameVariables(std::vector variables){
this->clearAvailableGameVariables();
- for(auto i : gameVariables) this->addAvailableGameVariable(i);
+ for(auto i : variables) this->addAvailableGameVariable(i);
}
- void DoomGame::addAvailableGameVariable(GameVariable var) {
+ void DoomGame::addAvailableGameVariable(GameVariable variable) {
if (!this->isRunning() &&
- std::find(this->availableGameVariables.begin(), this->availableGameVariables.end(), var)
+ std::find(this->availableGameVariables.begin(), this->availableGameVariables.end(), variable)
== this->availableGameVariables.end()) {
- this->availableGameVariables.push_back(var);
+ this->availableGameVariables.push_back(variable);
}
}
@@ -667,7 +667,3 @@ namespace vizdoom {
updateState();
}
}
-
-
-
-
diff --git a/src/lib_python/CMakeLists.txt b/src/lib_python/CMakeLists.txt
index 07d83e79b..a720239ba 100644
--- a/src/lib_python/CMakeLists.txt
+++ b/src/lib_python/CMakeLists.txt
@@ -42,9 +42,10 @@ configure_file(
)
set(VIZDOOM_PYTHON_SOURCES
- ${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomDocstrings.h
${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomGamePython.h
${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomGamePython.cpp
+ ${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomMethodsDocstrings.h
+ ${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomObjectsDocstrings.h
${VIZDOOM_PYTHON_SRC_DIR}/ViZDoomPythonModule.cpp)
pybind11_add_module(libvizdoom_python ${VIZDOOM_PYTHON_SOURCES})
diff --git a/src/lib_python/ViZDoomGamePython.h b/src/lib_python/ViZDoomGamePython.h
index 0f1ea0aec..6156c750e 100644
--- a/src/lib_python/ViZDoomGamePython.h
+++ b/src/lib_python/ViZDoomGamePython.h
@@ -122,24 +122,6 @@ namespace vizdoom {
void advanceAction(unsigned int tics = 1, bool updateState = true);
void respawnPlayer();
- // Overloaded functions instead of default arguments for pybind11
-
- void newEpisode_() { this->newEpisode(); };
- void newEpisode_str(std::string _str) { this->newEpisode(_str); };
-
- double makeAction_list(pyb::object const &_list){ return this->makeAction(_list); }
- double makeAction_list_int(pyb::object const &_list, unsigned int _int){ return this->makeAction(_list, _int); }
-
- void advanceAction_() { this->advanceAction(); }
- void advanceAction_int(unsigned int _int) { this->advanceAction(_int); }
- void advanceAction_int_bool(unsigned int _int, bool _bool) { this->advanceAction(_int, _bool); }
-
- void addAvailableButton_btn(Button _btn) { this->addAvailableButton(_btn); }
- void addAvailableButton_btn_double(Button _btn, double _double) { this->addAvailableButton(_btn, _double); }
-
- void replayEpisode_str(std::string _str) { this->replayEpisode(_str); }
- void replayEpisode_str_int(std::string _str, unsigned int _int) { this->replayEpisode(_str, _int); }
-
private:
GameStatePython* pyState;
diff --git a/src/lib_python/ViZDoomDocstrings.h b/src/lib_python/ViZDoomMethodsDocstrings.h
similarity index 90%
rename from src/lib_python/ViZDoomDocstrings.h
rename to src/lib_python/ViZDoomMethodsDocstrings.h
index b97bf12b5..0155a0ab6 100644
--- a/src/lib_python/ViZDoomDocstrings.h
+++ b/src/lib_python/ViZDoomMethodsDocstrings.h
@@ -1,11 +1,10 @@
-
/*
This file is autogenerated by scripts/create_python_docstrings_from_cpp_docs.py
- Do not edit it manually. Edit the Markdown files under docs/api_cpp/ directory instead and regenerate it.
+ Do not edit it manually. Edit the Markdown files under docs/api/cpp/ directory instead and regenerate it.
*/
-#ifndef __VIZDOOM_DOCSTRINGS_H__
-#define __VIZDOOM_DOCSTRINGS_H__
+#ifndef __VIZDOOM_METHODS_DOCSTRINGS_H__
+#define __VIZDOOM_METHODS_DOCSTRINGS_H__
namespace vizdoom {
namespace docstrings {
@@ -15,7 +14,7 @@ namespace DoomGamePython {
const char *init = R"DOCSTRING(Initializes ViZDoom game instance and starts a new episode.
After calling this method, the first state from a new episode will be available.
Some configuration options cannot be changed after calling this method.
-Init returns true when the game was started properly and false otherwise.)DOCSTRING";
+Init returns True when the game was started properly and False otherwise.)DOCSTRING";
const char *close = R"DOCSTRING(Closes ViZDoom game instance.
It is automatically invoked by the destructor.
@@ -54,12 +53,12 @@ If `updateState` is not set, the state will not be updated.)DOCSTRING";
Sets the player's action for the next tics, processes a specified number of tics,
updates the state and calculates a new reward, which is returned.)DOCSTRING";
- const char *isNewEpisode = R"DOCSTRING(Returns true if the current episode is in the initial state - the first state, no actions were performed yet.)DOCSTRING";
+ const char *isNewEpisode = R"DOCSTRING(Returns True if the current episode is in the initial state - the first state, no actions were performed yet.)DOCSTRING";
- const char *isEpisodeFinished = R"DOCSTRING(Returns true if the current episode is in the terminal state (is finished).
+ const char *isEpisodeFinished = R"DOCSTRING(Returns True if the current episode is in the terminal state (is finished).
`makeAction`.)DOCSTRING";
- const char *isPlayerDead = R"DOCSTRING(Returns true if the player is dead.
+ const char *isPlayerDead = R"DOCSTRING(Returns True if the player is dead.
In singleplayer, the player's death is equivalent to the end of the episode.
In multiplayer, when the player is dead `respawnPlayer` method can be called.)DOCSTRING";
@@ -145,8 +144,8 @@ Default value: 0)DOCSTRING";
const char *loadConfig = R"DOCSTRING(Loads configuration (resolution, available buttons, game variables etc.) from a configuration file.
In case of multiple invocations, older configurations will be overwritten by the recent ones.
Overwriting does not involve resetting to default values. Thus only overlapping parameters will be changed.
-The method returns true if the whole configuration file was correctly read and applied,
-false if the file contained errors.)DOCSTRING";
+The method returns True if the whole configuration file was correctly read and applied,
+False if the file contained errors.)DOCSTRING";
const char *getMode = R"DOCSTRING(Returns current mode (`PLAYER`, `SPECTATOR`, `ASYNC_PLAYER`, `ASYNC_SPECTATOR`).)DOCSTRING";
@@ -230,25 +229,25 @@ The format change affects only the buffers, so it will not have any effect on th
Default value: `CRCGCB`)DOCSTRING";
- const char *isDepthBufferEnabled = R"DOCSTRING(Returns true if the depth buffer is enabled.)DOCSTRING";
+ const char *isDepthBufferEnabled = R"DOCSTRING(Returns True if the depth buffer is enabled.)DOCSTRING";
const char *setDepthBufferEnabled = R"DOCSTRING(Enables rendering of the depth buffer, it will be available in the state.
Depth buffer will contain noise if `viz_nocheat` is enabled.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
- const char *isLabelsBufferEnabled = R"DOCSTRING(Returns true if the labels buffer is enabled.)DOCSTRING";
+ const char *isLabelsBufferEnabled = R"DOCSTRING(Returns True if the labels buffer is enabled.)DOCSTRING";
const char *setLabelsBufferEnabled = R"DOCSTRING(Enables rendering of the labels buffer, it will be available in the state with the vector of `Label`s.
LabelsBuffer will contain noise if `viz_nocheat` is enabled.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
- const char *isAutomapBufferEnabled = R"DOCSTRING(Returns true if the automap buffer is enabled.)DOCSTRING";
+ const char *isAutomapBufferEnabled = R"DOCSTRING(Returns True if the automap buffer is enabled.)DOCSTRING";
const char *setAutomapBufferEnabled = R"DOCSTRING(Enables rendering of the automap buffer, it will be available in the state.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setAutomapMode = R"DOCSTRING(Sets the automap mode (`NORMAL`, `WHOLE`, `OBJECTS`, `OBJECTS_WITH_SIZE`),
which determines what will be visible on it.
@@ -256,72 +255,72 @@ which determines what will be visible on it.
Default value: `NORMAL`)DOCSTRING";
const char *setAutomapRotate = R"DOCSTRING(Determine if the automap will be rotating with the player.
-If false, north always will be at the top of the buffer.
+If False, north always will be at the top of the buffer.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setAutomapRenderTextures = R"DOCSTRING(Determine if the automap will be textured, showing the floor textures.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderHud = R"DOCSTRING(Determine if the hud will be rendered in the game.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setRenderMinimalHud = R"DOCSTRING(Determine if the minimalistic version of the hud will be rendered instead of the full hud.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setRenderWeapon = R"DOCSTRING(Determine if the weapon held by the player will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderCrosshair = R"DOCSTRING(Determine if the crosshair will be rendered in the game.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setRenderDecals = R"DOCSTRING(Determine if the decals (marks on the walls) will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderParticles = R"DOCSTRING(Determine if the particles will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderEffectsSprites = R"DOCSTRING(Determine if some effects sprites (gun puffs, blood splats etc.) will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderMessages = R"DOCSTRING(Determine if in-game messages (information about pickups, kills, etc.) will be rendered in the game.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setRenderCorpses = R"DOCSTRING(Determine if actors' corpses will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderScreenFlashes = R"DOCSTRING(Determine if the screen flash effect upon taking damage or picking up items will be rendered in the game.
-Default value: true)DOCSTRING";
+Default value: True)DOCSTRING";
const char *setRenderAllFrames = R"DOCSTRING(Determine if all frames between states will be rendered (when skip greater than 1 is used).
Allows smooth preview but can reduce performance.
It only makes sense to use it if the window is visible.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setWindowVisible = R"DOCSTRING(Determines if ViZDoom's window will be visible.
ViZDoom with window disabled can be used on Linux systems without X Server.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setConsoleEnabled = R"DOCSTRING(Determines if ViZDoom's console output will be enabled.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *setSoundEnabled = R"DOCSTRING(Determines if ViZDoom's sound will be played.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *getScreenWidth = R"DOCSTRING(Returns game's screen width - width of all buffers.)DOCSTRING";
@@ -333,31 +332,31 @@ Default value: false)DOCSTRING";
const char *getScreenSize = R"DOCSTRING(Returns size in bytes of screen buffer and map buffer.)DOCSTRING";
- const char *isObjectsInfoEnabled = R"DOCSTRING(Returns true if the objects information is enabled.)DOCSTRING";
+ const char *isObjectsInfoEnabled = R"DOCSTRING(Returns True if the objects information is enabled.)DOCSTRING";
const char *setObjectsInfoEnabled = R"DOCSTRING(Enables information about all objects present in the current episode/level.
It will be available in the state.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
- const char *isSectorsInfoEnabled = R"DOCSTRING(Returns true if the information about sectors is enabled.)DOCSTRING";
+ const char *isSectorsInfoEnabled = R"DOCSTRING(Returns True if the information about sectors is enabled.)DOCSTRING";
const char *setSectorsInfoEnabled = R"DOCSTRING(Enables information about all sectors (map layout) present in the current episode/level.
It will be available in the state.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
- const char *isAudioBufferEnabled = R"DOCSTRING(Returns true if the audio buffer is enabled.)DOCSTRING";
+ const char *isAudioBufferEnabled = R"DOCSTRING(Returns True if the audio buffer is enabled.)DOCSTRING";
- const char *setAudioBufferEnabled = R"DOCSTRING(Returns true if the audio buffer is enabled.
+ const char *setAudioBufferEnabled = R"DOCSTRING(Returns True if the audio buffer is enabled.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *getAudioSamplingRate = R"DOCSTRING(Returns the sampling rate of the audio buffer.)DOCSTRING";
const char *setAudioSamplingRate = R"DOCSTRING(Sets the sampling rate of the audio buffer.
-Default value: false)DOCSTRING";
+Default value: False)DOCSTRING";
const char *getAudioBufferSize = R"DOCSTRING(Returns the size of the audio buffer.)DOCSTRING";
@@ -378,13 +377,13 @@ Default value: 4)DOCSTRING";
const char *secToDoomTics = R"DOCSTRING(Calculates the number of seconds that will pass during specified number of tics.)DOCSTRING";
const char *doomFixedToDouble = R"DOCSTRING(Converts fixed point numeral to a floating point value.
-Doom's engine internaly use fixed point numbers.
-If you read them directly from `USERX` variables,
+Doom's engine internally use fixed point numbers.
+If you read them directly from `USERX` variables,
you may want to convert them to floating point numbers.)DOCSTRING";
- const char *isBinaryButton = R"DOCSTRING(Returns true if button is binary button.)DOCSTRING";
+ const char *isBinaryButton = R"DOCSTRING(Returns True if button is binary button.)DOCSTRING";
- const char *isDeltaButton = R"DOCSTRING(Returns true if button is delta button.)DOCSTRING";
+ const char *isDeltaButton = R"DOCSTRING(Returns True if button is delta button.)DOCSTRING";
} // namespace docstrings
diff --git a/src/lib_python/ViZDoomObjectsDocstrings.h b/src/lib_python/ViZDoomObjectsDocstrings.h
new file mode 100644
index 000000000..de6bddb2f
--- /dev/null
+++ b/src/lib_python/ViZDoomObjectsDocstrings.h
@@ -0,0 +1,25 @@
+#ifndef __VIZDOOM_OBJECTS_DOCSTRINGS_H__
+#define __VIZDOOM_OBJECTS_DOCSTRINGS_H__
+
+namespace vizdoom {
+namespace docstrings {
+
+ const char *Mode = R"DOCSTRING( TODO )DOCSTRING";
+ const char *ScreenFormat = R"DOCSTRING( TODO )DOCSTRING";
+ const char *ScreenResolution = R"DOCSTRING( TODO )DOCSTRING";
+ const char *AutomapMode = R"DOCSTRING( TODO )DOCSTRING";
+ const char *Button = R"DOCSTRING( )DOCSTRING";
+ const char *GameVariable = R"DOCSTRING( TODO )DOCSTRING";
+ const char *SamplingRate = R"DOCSTRING( TODO )DOCSTRING";
+ const char *Label = R"DOCSTRING( TODO )DOCSTRING";
+ const char *Line = R"DOCSTRING( TODO )DOCSTRING";
+ const char *Sector = R"DOCSTRING( TODO )DOCSTRING";
+ const char *Object = R"DOCSTRING( TODO )DOCSTRING";
+ const char *ServerState = R"DOCSTRING( TODO )DOCSTRING";
+ const char *GameState = R"DOCSTRING( TODO )DOCSTRING";
+ const char *DoomGame = R"DOCSTRING( TODO )DOCSTRING";
+
+} // namespace docstrings
+} // namespace vizdoom
+
+#endif
diff --git a/src/lib_python/ViZDoomPythonModule.cpp b/src/lib_python/ViZDoomPythonModule.cpp
index 326135c41..c779dcb1d 100644
--- a/src/lib_python/ViZDoomPythonModule.cpp
+++ b/src/lib_python/ViZDoomPythonModule.cpp
@@ -24,7 +24,8 @@
#include "ViZDoom.h"
#include "ViZDoomGamePython.h"
#include "ViZDoomVersion.h"
-#include "ViZDoomDocstrings.h"
+#include "ViZDoomMethodsDocstrings.h"
+#include "ViZDoomObjectsDocstrings.h"
#include
#include
@@ -66,6 +67,7 @@ PYBIND11_MODULE(vizdoom, vz){
/* Helpers */
/*----------------------------------------------------------------------------------------------------------------*/
+ // These macros are used to make the code below shorter and less prone to typos
#define CONST_2_PYT(c) vz.attr( #c ) = c
/* vz.attr("CONST") = CONST */
@@ -79,9 +81,15 @@ PYBIND11_MODULE(vizdoom, vz){
#define FUNC_2_PYT(n, f) vz.def( n , f , docstrings::f )
/* vz.def("name", function, docstrings::function) */
+ #define FUNC_2_PYT_WITH_ARGS(n, f, a...) vz.def( n , f , docstrings::f , a)
+ /* vz.def("name", function, docstrings::function, args) */
+
#define CLASS_FUNC_2_PYT(n, cf) .def( n , &cf , docstrings::cf )
/* .def("name", &class::function, docstrings::class::function) */
+ #define CLASS_FUNC_2_PYT_WITH_ARGS(n, cf, a...) .def( n , &cf , docstrings::cf, a )
+ /* .def("name", &class::function, docstrings::class::function, args) */
+
/* Consts */
/*----------------------------------------------------------------------------------------------------------------*/
@@ -613,40 +621,35 @@ PYBIND11_MODULE(vizdoom, vz){
pyb::class_(vz, "DoomGame")
.def(pyb::init<>())
CLASS_FUNC_2_PYT("init", DoomGamePython::init)
- CLASS_FUNC_2_PYT("load_config", DoomGamePython::loadConfig)
+ CLASS_FUNC_2_PYT_WITH_ARGS("load_config", DoomGamePython::loadConfig, pyb::arg("config"))
CLASS_FUNC_2_PYT("close", DoomGamePython::close)
CLASS_FUNC_2_PYT("is_running", DoomGamePython::isRunning)
CLASS_FUNC_2_PYT("is_multiplayer_game", DoomGamePython::isMultiplayerGame)
CLASS_FUNC_2_PYT("is_recording_episode", DoomGamePython::isRecordingEpisode)
CLASS_FUNC_2_PYT("is_replaying_episode", DoomGamePython::isReplayingEpisode)
- .def("new_episode", &DoomGamePython::newEpisode_, docstrings::DoomGamePython::newEpisode)
- .def("new_episode", &DoomGamePython::newEpisode_str, docstrings::DoomGamePython::newEpisode)
- .def("replay_episode", &DoomGamePython::replayEpisode_str, docstrings::DoomGamePython::replayEpisode)
- .def("replay_episode", &DoomGamePython::replayEpisode_str_int, docstrings::DoomGamePython::replayEpisode)
+ CLASS_FUNC_2_PYT_WITH_ARGS("new_episode", DoomGamePython::newEpisode, pyb::arg("recording_file_path") = "")
+ CLASS_FUNC_2_PYT_WITH_ARGS("replay_episode", DoomGamePython::replayEpisode, pyb::arg("file_path"), pyb::arg("player") = 0)
CLASS_FUNC_2_PYT("is_episode_finished", DoomGamePython::isEpisodeFinished)
CLASS_FUNC_2_PYT("is_new_episode", DoomGamePython::isNewEpisode)
CLASS_FUNC_2_PYT("is_player_dead", DoomGamePython::isPlayerDead)
CLASS_FUNC_2_PYT("respawn_player", DoomGamePython::respawnPlayer)
- CLASS_FUNC_2_PYT("set_action", DoomGamePython::setAction)
- .def("make_action", &DoomGamePython::makeAction_list, docstrings::DoomGamePython::makeAction)
- .def("make_action", &DoomGamePython::makeAction_list_int, docstrings::DoomGamePython::makeAction)
- .def("advance_action", &DoomGamePython::advanceAction_, docstrings::DoomGamePython::advanceAction)
- .def("advance_action", &DoomGamePython::advanceAction_int, docstrings::DoomGamePython::advanceAction)
- .def("advance_action", &DoomGamePython::advanceAction_int_bool, docstrings::DoomGamePython::advanceAction)
- CLASS_FUNC_2_PYT("save", DoomGamePython::save)
- CLASS_FUNC_2_PYT("load", DoomGamePython::load)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_action", DoomGamePython::setAction, pyb::arg("action"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("make_action", DoomGamePython::makeAction, pyb::arg("action"), pyb::arg("tics") = 1)
+ CLASS_FUNC_2_PYT_WITH_ARGS("advance_action", DoomGamePython::advanceAction, pyb::arg("tics") = 1, pyb::arg("update_state") = true)
+ CLASS_FUNC_2_PYT_WITH_ARGS("save", DoomGamePython::save, pyb::arg("file_path"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("load", DoomGamePython::load, pyb::arg("file_path"))
.def("get_state", &DoomGamePython::getState, pyb::return_value_policy::take_ownership, docstrings::DoomGamePython::getState)
.def("get_server_state", &DoomGamePython::getServerState, pyb::return_value_policy::take_ownership, docstrings::DoomGamePython::getServerState)
- CLASS_FUNC_2_PYT("get_game_variable", DoomGamePython::getGameVariable)
- CLASS_FUNC_2_PYT("get_button", DoomGamePython::getButton)
+ CLASS_FUNC_2_PYT_WITH_ARGS("get_game_variable", DoomGamePython::getGameVariable, pyb::arg("variable"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("get_button", DoomGamePython::getButton, pyb::arg("button"))
CLASS_FUNC_2_PYT("get_living_reward", DoomGamePython::getLivingReward)
- CLASS_FUNC_2_PYT("set_living_reward", DoomGamePython::setLivingReward)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_living_reward", DoomGamePython::setLivingReward, pyb::arg("living_reward"))
CLASS_FUNC_2_PYT("get_death_penalty", DoomGamePython::getDeathPenalty)
- CLASS_FUNC_2_PYT("set_death_penalty", DoomGamePython::setDeathPenalty)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_death_penalty", DoomGamePython::setDeathPenalty, pyb::arg("death_penalty"))
CLASS_FUNC_2_PYT("get_last_reward", DoomGamePython::getLastReward)
CLASS_FUNC_2_PYT("get_total_reward", DoomGamePython::getTotalReward)
@@ -654,86 +657,85 @@ PYBIND11_MODULE(vizdoom, vz){
CLASS_FUNC_2_PYT("get_last_action", DoomGamePython::getLastAction)
CLASS_FUNC_2_PYT("get_available_game_variables", DoomGamePython::getAvailableGameVariables)
- CLASS_FUNC_2_PYT("set_available_game_variables", DoomGamePython::setAvailableGameVariables)
- CLASS_FUNC_2_PYT("add_available_game_variable", DoomGamePython::addAvailableGameVariable)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_available_game_variables", DoomGamePython::setAvailableGameVariables, pyb::arg("variables"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("add_available_game_variable", DoomGamePython::addAvailableGameVariable, pyb::arg("variable"))
CLASS_FUNC_2_PYT("clear_available_game_variables", DoomGamePython::clearAvailableGameVariables)
CLASS_FUNC_2_PYT("get_available_game_variables_size", DoomGamePython::getAvailableGameVariablesSize)
CLASS_FUNC_2_PYT("get_available_buttons", DoomGamePython::getAvailableButtons)
- CLASS_FUNC_2_PYT("set_available_buttons", DoomGamePython::setAvailableButtons)
- .def("add_available_button", &DoomGamePython::addAvailableButton_btn, docstrings::DoomGamePython::addAvailableButton)
- .def("add_available_button", &DoomGamePython::addAvailableButton_btn_double, docstrings::DoomGamePython::addAvailableButton)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_available_buttons", DoomGamePython::setAvailableButtons, pyb::arg("buttons"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("add_available_button", DoomGamePython::addAvailableButton, pyb::arg("button"), pyb::arg("max_value") = -1)
CLASS_FUNC_2_PYT("clear_available_buttons", DoomGamePython::clearAvailableButtons)
CLASS_FUNC_2_PYT("get_available_buttons_size", DoomGamePython::getAvailableButtonsSize)
- CLASS_FUNC_2_PYT("set_button_max_value", DoomGamePython::setButtonMaxValue)
- CLASS_FUNC_2_PYT("get_button_max_value", DoomGamePython::getButtonMaxValue)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_button_max_value", DoomGamePython::setButtonMaxValue, pyb::arg("button"), pyb::arg("max_value"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("get_button_max_value", DoomGamePython::getButtonMaxValue, pyb::arg("button"))
- CLASS_FUNC_2_PYT("add_game_args", DoomGamePython::addGameArgs)
+ CLASS_FUNC_2_PYT_WITH_ARGS("add_game_args", DoomGamePython::addGameArgs, pyb::arg("args"))
CLASS_FUNC_2_PYT("clear_game_args", DoomGamePython::clearGameArgs)
- CLASS_FUNC_2_PYT("send_game_command", DoomGamePython::sendGameCommand)
+ CLASS_FUNC_2_PYT_WITH_ARGS("send_game_command", DoomGamePython::sendGameCommand, pyb::arg("cmd"))
CLASS_FUNC_2_PYT("get_mode", DoomGamePython::getMode)
- CLASS_FUNC_2_PYT("set_mode", DoomGamePython::setMode)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_mode", DoomGamePython::setMode, pyb::arg("mode"))
CLASS_FUNC_2_PYT("get_ticrate", DoomGamePython::getTicrate)
- CLASS_FUNC_2_PYT("set_ticrate", DoomGamePython::setTicrate)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_ticrate", DoomGamePython::setTicrate, pyb::arg("button"))
- CLASS_FUNC_2_PYT("set_vizdoom_path", DoomGamePython::setViZDoomPath)
- CLASS_FUNC_2_PYT("set_doom_game_path", DoomGamePython::setDoomGamePath)
- CLASS_FUNC_2_PYT("set_doom_scenario_path", DoomGamePython::setDoomScenarioPath)
- CLASS_FUNC_2_PYT("set_doom_map", DoomGamePython::setDoomMap)
- CLASS_FUNC_2_PYT("set_doom_skill", DoomGamePython::setDoomSkill)
- CLASS_FUNC_2_PYT("set_doom_config_path", DoomGamePython::setDoomConfigPath)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_vizdoom_path", DoomGamePython::setViZDoomPath, pyb::arg("button"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_doom_game_path", DoomGamePython::setDoomGamePath, pyb::arg("button"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_doom_scenario_path", DoomGamePython::setDoomScenarioPath, pyb::arg("button"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_doom_map", DoomGamePython::setDoomMap, pyb::arg("button"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_doom_skill", DoomGamePython::setDoomSkill, pyb::arg("button"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_doom_config_path", DoomGamePython::setDoomConfigPath, pyb::arg("button"))
CLASS_FUNC_2_PYT("get_seed", DoomGamePython::getSeed)
- CLASS_FUNC_2_PYT("set_seed", DoomGamePython::setSeed)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_seed", DoomGamePython::setSeed, pyb::arg("seed"))
CLASS_FUNC_2_PYT("get_episode_start_time", DoomGamePython::getEpisodeStartTime)
- CLASS_FUNC_2_PYT("set_episode_start_time", DoomGamePython::setEpisodeStartTime)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_episode_start_time", DoomGamePython::setEpisodeStartTime, pyb::arg("start_time"))
CLASS_FUNC_2_PYT("get_episode_timeout", DoomGamePython::getEpisodeTimeout)
- CLASS_FUNC_2_PYT("set_episode_timeout", DoomGamePython::setEpisodeTimeout)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_episode_timeout", DoomGamePython::setEpisodeTimeout, pyb::arg("timeout"))
CLASS_FUNC_2_PYT("get_episode_time", DoomGamePython::getEpisodeTime)
- CLASS_FUNC_2_PYT("set_console_enabled", DoomGamePython::setConsoleEnabled)
- CLASS_FUNC_2_PYT("set_sound_enabled", DoomGamePython::setSoundEnabled)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_console_enabled", DoomGamePython::setConsoleEnabled, pyb::arg("console"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_sound_enabled", DoomGamePython::setSoundEnabled, pyb::arg("sound"))
CLASS_FUNC_2_PYT("is_audio_buffer_enabled", DoomGamePython::isAudioBufferEnabled)
- CLASS_FUNC_2_PYT("set_audio_buffer_enabled", DoomGamePython::setAudioBufferEnabled)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_audio_buffer_enabled", DoomGamePython::setAudioBufferEnabled, pyb::arg("audio_buffer"))
CLASS_FUNC_2_PYT("get_audio_sampling_rate", DoomGamePython::getAudioSamplingRate)
- CLASS_FUNC_2_PYT("set_audio_sampling_rate", DoomGamePython::setAudioSamplingRate)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_audio_sampling_rate", DoomGamePython::setAudioSamplingRate, pyb::arg("sampling_rate"))
CLASS_FUNC_2_PYT("get_audio_buffer_size", DoomGamePython::getAudioBufferSize)
- CLASS_FUNC_2_PYT("set_audio_buffer_size", DoomGamePython::setAudioBufferSize)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_audio_buffer_size", DoomGamePython::setAudioBufferSize, pyb::arg("buffer_size"))
- CLASS_FUNC_2_PYT("set_screen_resolution", DoomGamePython::setScreenResolution)
- CLASS_FUNC_2_PYT("set_screen_format", DoomGamePython::setScreenFormat)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_screen_resolution", DoomGamePython::setScreenResolution, pyb::arg("resolution"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_screen_format", DoomGamePython::setScreenFormat, pyb::arg("format"))
CLASS_FUNC_2_PYT("is_depth_buffer_enabled", DoomGamePython::isDepthBufferEnabled)
- CLASS_FUNC_2_PYT("set_depth_buffer_enabled", DoomGamePython::setDepthBufferEnabled)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_depth_buffer_enabled", DoomGamePython::setDepthBufferEnabled, pyb::arg("depth_buffer"))
CLASS_FUNC_2_PYT("is_labels_buffer_enabled", DoomGamePython::isLabelsBufferEnabled)
- CLASS_FUNC_2_PYT("set_labels_buffer_enabled", DoomGamePython::setLabelsBufferEnabled)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_labels_buffer_enabled", DoomGamePython::setLabelsBufferEnabled, pyb::arg("labels_buffer"))
CLASS_FUNC_2_PYT("is_automap_buffer_enabled", DoomGamePython::isAutomapBufferEnabled)
- CLASS_FUNC_2_PYT("set_automap_buffer_enabled", DoomGamePython::setAutomapBufferEnabled)
- CLASS_FUNC_2_PYT("set_automap_mode", DoomGamePython::setAutomapMode)
- CLASS_FUNC_2_PYT("set_automap_rotate", DoomGamePython::setAutomapRotate)
- CLASS_FUNC_2_PYT("set_automap_render_textures", DoomGamePython::setAutomapRenderTextures)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_automap_buffer_enabled", DoomGamePython::setAutomapBufferEnabled, pyb::arg("automap_buffer"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_automap_mode", DoomGamePython::setAutomapMode, pyb::arg("mode"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_automap_rotate", DoomGamePython::setAutomapRotate, pyb::arg("rotate"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_automap_render_textures", DoomGamePython::setAutomapRenderTextures, pyb::arg("textures"))
CLASS_FUNC_2_PYT("is_objects_info_enabled", DoomGamePython::isObjectsInfoEnabled)
- CLASS_FUNC_2_PYT("set_objects_info_enabled", DoomGamePython::setObjectsInfoEnabled)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_objects_info_enabled", DoomGamePython::setObjectsInfoEnabled, pyb::arg("objects_info"))
CLASS_FUNC_2_PYT("is_sectors_info_enabled", DoomGamePython::isSectorsInfoEnabled)
- CLASS_FUNC_2_PYT("set_sectors_info_enabled", DoomGamePython::setSectorsInfoEnabled)
-
- CLASS_FUNC_2_PYT("set_render_hud", DoomGamePython::setRenderHud)
- CLASS_FUNC_2_PYT("set_render_minimal_hud", DoomGamePython::setRenderMinimalHud)
- CLASS_FUNC_2_PYT("set_render_weapon", DoomGamePython::setRenderWeapon)
- CLASS_FUNC_2_PYT("set_render_crosshair", DoomGamePython::setRenderCrosshair)
- CLASS_FUNC_2_PYT("set_render_decals", DoomGamePython::setRenderDecals)
- CLASS_FUNC_2_PYT("set_render_particles", DoomGamePython::setRenderParticles)
- CLASS_FUNC_2_PYT("set_render_effects_sprites", DoomGamePython::setRenderEffectsSprites)
- CLASS_FUNC_2_PYT("set_render_messages", DoomGamePython::setRenderMessages)
- CLASS_FUNC_2_PYT("set_render_corpses", DoomGamePython::setRenderCorpses)
- CLASS_FUNC_2_PYT("set_render_screen_flashes", DoomGamePython::setRenderScreenFlashes)
- CLASS_FUNC_2_PYT("set_render_all_frames", DoomGamePython::setRenderAllFrames)
- CLASS_FUNC_2_PYT("set_window_visible", DoomGamePython::setWindowVisible)
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_sectors_info_enabled", DoomGamePython::setSectorsInfoEnabled, pyb::arg("sectors_info"))
+
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_hud", DoomGamePython::setRenderHud, pyb::arg("hud"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_minimal_hud", DoomGamePython::setRenderMinimalHud, pyb::arg("min_hud"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_weapon", DoomGamePython::setRenderWeapon, pyb::arg("weapon"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_crosshair", DoomGamePython::setRenderCrosshair, pyb::arg("crosshair"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_decals", DoomGamePython::setRenderDecals, pyb::arg("decals"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_particles", DoomGamePython::setRenderParticles, pyb::arg("particles"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_effects_sprites", DoomGamePython::setRenderEffectsSprites, pyb::arg("sprites"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_messages", DoomGamePython::setRenderMessages, pyb::arg("messages"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_corpses", DoomGamePython::setRenderCorpses, pyb::arg("bodies"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_screen_flashes", DoomGamePython::setRenderScreenFlashes, pyb::arg("flashes"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_render_all_frames", DoomGamePython::setRenderAllFrames, pyb::arg("all_frames"))
+ CLASS_FUNC_2_PYT_WITH_ARGS("set_window_visible", DoomGamePython::setWindowVisible, pyb::arg("visiblity"))
CLASS_FUNC_2_PYT("get_screen_width", DoomGamePython::getScreenWidth)
CLASS_FUNC_2_PYT("get_screen_height", DoomGamePython::getScreenHeight)
CLASS_FUNC_2_PYT("get_screen_channels", DoomGamePython::getScreenChannels)
@@ -745,15 +747,15 @@ PYBIND11_MODULE(vizdoom, vz){
/* Utilities */
/*----------------------------------------------------------------------------------------------------------------*/
- FUNC_2_PYT("doom_tics_to_ms", doomTicsToMs);
- FUNC_2_PYT("ms_to_doom_tics", msToDoomTics);
- FUNC_2_PYT("doom_tics_to_sec", doomTicsToSec);
- FUNC_2_PYT("sec_to_doom_tics", secToDoomTics);
- vz.def("doom_fixed_to_double", doomFixedToDouble_int, docstrings::doomFixedToDouble);
- vz.def("doom_fixed_to_double", doomFixedToDouble_double, docstrings::doomFixedToDouble);
- vz.def("doom_fixed_to_float", doomFixedToDouble_int, docstrings::doomFixedToDouble);
- vz.def("doom_fixed_to_float", doomFixedToDouble_double, docstrings::doomFixedToDouble);
- FUNC_2_PYT("is_binary_button", isBinaryButton);
- FUNC_2_PYT("is_delta_button", isDeltaButton);
+ FUNC_2_PYT_WITH_ARGS("doom_tics_to_ms", doomTicsToMs, pyb::arg("doom_tics"), pyb::arg("fps") = 35);
+ FUNC_2_PYT_WITH_ARGS("ms_to_doom_tics", msToDoomTics, pyb::arg("doom_tics"), pyb::arg("fps") = 35);
+ FUNC_2_PYT_WITH_ARGS("doom_tics_to_sec", doomTicsToSec, pyb::arg("doom_tics"), pyb::arg("fps") = 35);
+ FUNC_2_PYT_WITH_ARGS("sec_to_doom_tics", secToDoomTics, pyb::arg("doom_tics"), pyb::arg("fps") = 35);
+ vz.def("doom_fixed_to_double", doomFixedToDouble_int);
+ vz.def("doom_fixed_to_double", doomFixedToDouble_double);
+ vz.def("doom_fixed_to_float", doomFixedToDouble_int);
+ vz.def("doom_fixed_to_float", doomFixedToDouble_double);
+ FUNC_2_PYT_WITH_ARGS("is_binary_button", isBinaryButton, pyb::arg("button"));
+ FUNC_2_PYT_WITH_ARGS("is_delta_button", isDeltaButton, pyb::arg("button"));
}
diff --git a/tests/test_docstrings.py b/tests/test_docstrings.py
index f2e3709ef..7952f26af 100755
--- a/tests/test_docstrings.py
+++ b/tests/test_docstrings.py
@@ -1,17 +1,30 @@
#!/usr/bin/env python3
+
+import re
+
import vizdoom as vzd
-def _check_object_docstrings(object):
+def _get_object_methods(object):
object_methods = [
method_name
for method_name in dir(object)
- if callable(getattr(object, method_name))
+ if callable(getattr(object, method_name)) and not method_name.startswith("_")
]
+ return object_methods
+
+
+def _check_object_docstrings(object):
+ object_methods = _get_object_methods(object)
for method in object_methods:
- assert method.__doc__ is not None, f"Method {method} has no docstring"
+ method_doc = eval(f"object.{method}.__doc__")
+ assert method_doc is not None, f"Method {method} has no docstring"
+
+ # Check if there is correct signature in docstring (with proper argument names)
+ m = re.search(r"arg[0-9]+", method_doc)
+ assert m is None, f"Method {method} has arguments without names"
def test_docstrings():
diff --git a/tests/test_make_action.py b/tests/test_make_action.py
index 75ddf3a2d..d9ae8dce2 100755
--- a/tests/test_make_action.py
+++ b/tests/test_make_action.py
@@ -25,6 +25,23 @@ def _compare_actions(action_a, action_b):
def _test_make_action_input(type_name, type_args={}):
+ def _make_func(game, action, tics=1):
+ return game.make_action(action, tics)
+
+ def _set_advance_func(game, action, tics=1):
+ game.set_action(action)
+ game.advance_action(tics, True)
+ return game.get_last_reward()
+
+ __test_make_action_input(_make_func, type_name, type_args=type_args)
+ __test_make_action_input(_set_advance_func, type_name, type_args=type_args)
+
+
+def __test_make_action_input(
+ make_action_func,
+ type_name,
+ type_args={},
+):
print(
f"Testing make_action with {type_name.__name__}([], {type_args}) type as input ..."
)
@@ -51,23 +68,31 @@ def _test_make_action_input(type_name, type_args={}):
_compare_actions(next_action, type_name(game.get_last_action(), **type_args))
# make_action() without skipping frames
- game.make_action(next_action)
+ make_action_func(game, next_action)
+
+ # use set_action() instead of make_action()
+ game.set_action(next_action)
+ game.advance_action()
# make_action() with negative frames and other types
error_msg = "make_action() should raise TypeError when called with negative frames or type other than unsigned int"
- _test_exception(lambda: game.make_action(next_action, -10), TypeError, error_msg)
- _test_exception(lambda: game.make_action(next_action, "10"), TypeError, error_msg)
+ _test_exception(
+ lambda: make_action_func(game, next_action, -10), TypeError, error_msg
+ )
+ _test_exception(
+ lambda: make_action_func(game, next_action, "10"), TypeError, error_msg
+ )
# make_action() with too short action
next_action = type_name([1, 0], **type_args)
- game.make_action(next_action, 8)
+ make_action_func(game, next_action, 8)
assert prev_pos_y < game.get_game_variable(vzd.GameVariable.POSITION_Y)
prev_pos_y = game.get_game_variable(vzd.GameVariable.POSITION_Y)
_compare_actions(next_action, type_name(game.get_last_action()[:2], **type_args))
# make_action() with too long action
next_action = type_name([1, 0, 1, 0], **type_args)
- game.make_action(next_action, 8)
+ make_action_func(game, next_action, 8)
assert prev_pos_y < game.get_game_variable(vzd.GameVariable.POSITION_Y)
prev_pos_y = game.get_game_variable(vzd.GameVariable.POSITION_Y)
assert prev_ammo > game.get_game_variable(vzd.GameVariable.AMMO2)
@@ -76,7 +101,7 @@ def _test_make_action_input(type_name, type_args={}):
# make_action() with values other than 0 and 1
next_action = type_name([0, 5, -5], **type_args)
- game.make_action(next_action, 16)
+ make_action_func(game, next_action, 16)
assert prev_pos_y > game.get_game_variable(vzd.GameVariable.POSITION_Y)
assert prev_ammo > game.get_game_variable(vzd.GameVariable.AMMO2)
_compare_actions(next_action[:3], type_name(game.get_last_action(), **type_args))