Skip to content

Commit

Permalink
Added isMultiplayerGame method and some missing methods in Python and…
Browse files Browse the repository at this point in the history
… Lua bindings

Former-commit-id: adda45c
  • Loading branch information
mwydmuch committed Jun 6, 2017
1 parent 93ccea2 commit 4c45029
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(ViZDoom)
#-----------------------------------------------------------------------------------------------------------------------
set(ViZDoom_MAJOR_VERSION 1)
set(ViZDoom_MINOR_VERSION 1)
set(ViZDoom_PATCH_VERSION 1)
set(ViZDoom_PATCH_VERSION 2)
set(ViZDoom_VERSION ${ViZDoom_MAJOR_VERSION}.${ViZDoom_MINOR_VERSION}.${ViZDoom_PATCH_VERSION})
set(ViZDoom_VERSION_STR ${ViZDoom_VERSION})
set(ViZDoom_VERSION_ID ${ViZDoom_MAJOR_VERSION}${ViZDoom_MINOR_VERSION}${ViZDoom_PATCH_VERSION})
Expand Down
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
## Changes in 1.1.2

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

#### Missing methods
- Added `isRunning`, `isDepthBufferEnabled`, `isLabelsBufferEnabled` and `isAutomapBufferEnabled` missing methods to Python and Lua bindings.


## Changes in 1.1.1

Expand Down
64 changes: 45 additions & 19 deletions doc/DoomGame.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [newEpisode](#newEpisode)
* [replayEpisode](#replayEpisode)
* [isRunning](#isRunning)
* [isMultiplayerGame](#isMultiplayerGame)
* [setAction](#setAction)
* [advanceAction](#advanceAction)
* [makeAction](#makeAction)
Expand Down Expand Up @@ -138,7 +139,7 @@ Game can be initialized again after being closed.
| Java | `void newEpisode(String recordFilePath = "")` |
| Python | `void new_episode(str recordFilePath = "")` |

Changed in 1.1
Changed in 1.1.0

Initializes a new episode. All rewards, variables and state are restarted.
After calling this method, first state from new episode will be available.
Expand All @@ -157,7 +158,7 @@ Then the rest of the players must also call this method to start a new episode.
| Java | `void replayEpisode(String filePath, int player = 0)` |
| Python | `void replay_episode(str filePath, int player = 0)` |

Added in 1.1
Added in 1.1.0

Replays recorded episode from the given file and using perspective of the specified player.
Players are numered from 1, `player` equal to 0 results in replaying demo using perspective
Expand All @@ -169,6 +170,7 @@ See also:
- [examples/python/record_episodes.py](https://github.com/mwydmuch/ViZDoom/tree/master/examples/python/record_episodes.py),
- [examples/python/record_multiplayer.py](https://github.com/mwydmuch/ViZDoom/tree/master/examples/python/record_multiplayer.py).


---
### <a name="isRunning"></a> `isRunning`

Expand All @@ -181,6 +183,20 @@ See also:
Checks if the ViZDoom game instance is running.


---
### <a name="isMultiplayerGame"></a> `isMultiplayerGame`

| C++ | `bool isMultiplayerGame()` |
| :-- | :-- |
| Lua | `boolean isMultiplayerGame()` |
| Java | `boolean isMultiplayerGame()` |
| Python | `bool is_multiplayer_game()` |

Added in 1.1.2

Checks if the game is in multiplayer mode.


---
### <a name="setAction"></a> `setAction`

Expand Down Expand Up @@ -274,6 +290,9 @@ In multiplayer when player is dead [`respawnPlayer`](#respawnPlayer) can be call
This method respawns player after death in multiplayer mode.
After calling this method, first state after respawn will be available.

See also:
- [`isMultiplayerGame`](#isMultiplayerGame)


---
### <a name="sendGameCommand"></a> `sendGameCommand`
Expand All @@ -299,7 +318,7 @@ See also: [ZDoom Wiki](http://zdoom.org/wiki/Console)
| Java | `GameState getState()` |
| Python | `GameState get_state()` |

Changed in 1.1
Changed in 1.1.0

Returns [`GameState`](Types.md#gamestate) object with the current game state.
If game is not running or episode is finished `nullptr/null/None` will be returned.
Expand Down Expand Up @@ -405,6 +424,7 @@ Clears all available `Buttons` added so far.
See also:
- [`Types: Button`](Types.md#button)


---
### <a name="getAvailableButtonsSize"></a> `getAvailableButtonsSize`

Expand All @@ -419,6 +439,7 @@ Returns the number of available `Buttons`.
See also:
- [`Types: Button`](Types.md#button)


---
### <a name="setButtonMaxValue"></a> `setButtonMaxValue`

Expand All @@ -436,6 +457,7 @@ Constraints limit applies in all Modes.
See also:
- [`Types: Button`](Types.md#button)


---
### <a name="getButtonMaxValue"></a> `getButtonMaxValue`

Expand Down Expand Up @@ -504,6 +526,7 @@ See also:
- [`Types: GameVariable`](Types.md#gamevariable)
- [`ConfigFile: List`](ConfigFile.md#list)


---
### <a name="clearAvailableGameVariables"></a> `clearAvailableGameVariables`

Expand All @@ -519,6 +542,7 @@ See also:
- [`Types: GameVariable`](Types.md#gamevariable)
- [`ConfigFile: List`](ConfigFile.md#list)


---
### <a name="getAvailableGameVariablesSize"></a> `getAvailableGameVariablesSize`

Expand All @@ -534,6 +558,7 @@ See also:
- [`Types: GameVariable`](Types.md#gamevariable)
- [`ConfigFile: List`](ConfigFile.md#list)


---
### <a name="getGameVariable"></a> `getGameVariable`

Expand Down Expand Up @@ -685,6 +710,7 @@ false if file was contained errors.
See also:
- [ConfigFile](ConfigFile.md)


---
### <a name="getMode"></a> `getMode`

Expand Down Expand Up @@ -725,7 +751,7 @@ See also:
| Java | `int getTicrate()` |
| Python | `int get_ticrate()` |

Added in 1.1
Added in 1.1.0

Returns current ticrate.

Expand All @@ -739,7 +765,7 @@ Returns current ticrate.
| Java | `void setTicrate(int ticrate)` |
| Python | `void set_ticrate(int ticrate)` |

Added in 1.1
Added in 1.1.0

Sets ticrate for ASNYC Modes - number of tics executed per second.

Expand Down Expand Up @@ -1013,7 +1039,7 @@ See also:
| Java | `boolean isDepthBufferEnabled()` |
| Python | `bool isDepthBufferEnabled()` |

Added in 1.1
Added in 1.1.0

Returns true if the depth buffer is enabled.

Expand All @@ -1027,7 +1053,7 @@ Returns true if the depth buffer is enabled.
| Java | `void setDepthBufferEnabled(boolean depthBuffer)` |
| Python | `void set_depth_buffer_enabled(bool depthBuffer)` |

Added in 1.1
Added in 1.1.0

Enables rendering of the depth buffer, it will be available in state.

Expand All @@ -1039,6 +1065,7 @@ See also:
- [`Types: GameState`](Types.md#gamestate)
- [examples/python/buffers.py](https://github.com/mwydmuch/ViZDoom/tree/master/examples/python/buffers.py),


---
### <a name="isLabelsBufferEnabled"></a> `isLabelsBufferEnabled`

Expand All @@ -1048,7 +1075,7 @@ See also:
| Java | `boolean isLabelsBufferEnabled()` |
| Python | `bool isLabelsBufferEnabled()` |

Added in 1.1
Added in 1.1.0

Returns true if the labels buffer is enabled.

Expand All @@ -1062,7 +1089,7 @@ Returns true if the labels buffer is enabled.
| Java | `void setLabelsBufferEnabled(boolean labelsBuffer)` |
| Python | `void set_labels_buffer_enabled(bool labelsBuffer)` |

Added in 1.1
Added in 1.1.0

Enables rendering of the labels buffer, it will be available in state with vector of `Label`s.

Expand All @@ -1077,7 +1104,6 @@ See also:
- [examples/python/buffers.py](https://github.com/mwydmuch/ViZDoom/tree/master/examples/python/buffers.py),



---
### <a name="isAutomapBufferEnabled"></a> `isAutomapBufferEnabled`

Expand All @@ -1087,7 +1113,7 @@ See also:
| Java | `boolean isAutomapBufferEnabled()` |
| Python | `bool isAutomapBufferEnabled()` |

Added in 1.1
Added in 1.1.0

Returns true if the automap buffer is enabled.

Expand All @@ -1101,7 +1127,7 @@ Returns true if the automap buffer is enabled.
| Java | `void setAutomapBufferEnabled(boolean automapBuffer)` |
| Python | `void set_automap_buffer_enabled(bool automapBuffer)` |

Added in 1.1
Added in 1.1.0

Enables rendering of the automap buffer, it will be available in state.

Expand All @@ -1123,7 +1149,7 @@ See also:
| Java | `void setAutomapMode(AutomapMode mode)` |
| Python | `void set_automap_mode(AutomapMode mode)` |

Added in 1.1
Added in 1.1.0

Sets the automap mode (`NORMAL`, `WHOLE`, `OBJECTS`, `OBJECTS_WITH_SIZE`) with determine what will be visible on it.

Expand All @@ -1144,7 +1170,7 @@ See also:
| Java | `void setAutomapRotate(boolean rotate)` |
| Python | `void set_automap_rotate(bool rotate)` |

Added in 1.1
Added in 1.1.0

Determine if the automap will be rotating with player, if false, north always will be at the top of the buffer.

Expand All @@ -1162,7 +1188,7 @@ Config key: `automapRotate/automap_rotate`
| Java | `void setAutomapRenderTextures(boolean textures)` |
| Python | `void set_automap_render_textures(bool textures)` |

Added in 1.1
Added in 1.1.0

Determine if the automap will be textured, showing the floor textures.

Expand Down Expand Up @@ -1196,7 +1222,7 @@ Config key: `renderHud/render_hud`
| Java | `void setRenderMinimalHud(boolean minHud)` |
| Python | `void set_render_minimal_hud(bool minHud)` |

Added in 1.1
Added in 1.1.0

Determine if minimalistic version of hud will be rendered instead of full hud.

Expand Down Expand Up @@ -1278,7 +1304,7 @@ Config key: `renderParticles/render_particles`
| Java | `void setRenderEffectsSprites(boolean sprites)` |
| Python | `void set_render_effects_sprites(bool sprites)` |

Added in 1.1
Added in 1.1.0

Determine if some effects sprites (gun pufs, blood splats etc.) will be rendered in game.

Expand All @@ -1296,7 +1322,7 @@ Config key: `renderEffectsSprites/render_effects_sprites`
| Java | `void setRenderMessages(boolean messages)` |
| Python | `void set_render_messages(bool messages)` |

Added in 1.1
Added in 1.1.0

Determine if ingame messages (information about pickups, kills etc.) will be rendered in game.

Expand All @@ -1314,7 +1340,7 @@ Config key: `renderMessages/render_messages`
| Java | `void setRenderCorpses(boolean corpses)` |
| Python | `void set_render_corpsess(bool corpses)` |

Added in 1.1
Added in 1.1.0

Determine if actors' corpses will be rendered in game.

Expand Down
2 changes: 1 addition & 1 deletion doc/Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
- `std::vector<Label> / table / Label[] / list` **labels**

**number** - number of the state in the episode.
**tic** - ingame time, 1 tic is 1/35 of second in the game world.
**tic** - ingame time, 1 tic is 1/35 of second in the game world. Added in 1.1.1.


See also:
Expand Down
1 change: 1 addition & 0 deletions include/ViZDoomGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace vizdoom {
void newEpisode(std::string filePath = "");
void replayEpisode(std::string filePath, unsigned int player = 0);
bool isRunning();
bool isMultiplayerGame();

void setAction(std::vector<double> const &actions);
void advanceAction(unsigned int tics = 1, bool updateState = true);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/ViZDoomGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ namespace vizdoom {
return this->running && this->doomController->isDoomRunning();
}

bool DoomGame::isMultiplayerGame() {
return this->running && this->doomController->isMultiplayerGame();
}

void DoomGame::newEpisode(std::string filePath) {

if (!this->isRunning()) throw ViZDoomIsNotRunningException();
Expand Down
1 change: 1 addition & 0 deletions src/lib_java/ViZDoomGameJava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ JNI_METHOD(void, newEpisode__Ljava_lang_String, newEpisode_str, jstring)
JNI_METHOD(void, replayEpisode__Ljava_lang_String_2, replayEpisode_str, jstring)
JNI_METHOD(void, replayEpisode__Ljava_lang_String_2I, replayEpisode_str_int, jstring, jint)
JNI_METHOD(jboolean, isRunning, isRunning)
JNI_METHOD(jboolean, isMultiplayerGame, isMultiplayerGame)
JNI_METHOD(void, setAction, setAction, jdoubleArray)
JNI_METHOD(void, advanceAction__, advanceAction_)
JNI_METHOD(void, advanceAction__I, advanceAction_int, jint)
Expand Down
1 change: 1 addition & 0 deletions src/lib_java/ViZDoomGameJava.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ JNI_EXPORT(void, newEpisode__Ljava_lang_String, jstring);
JNI_EXPORT(void, replayEpisode__Ljava_lang_String_2, jstring);
JNI_EXPORT(void, replayEpisode__Ljava_lang_String_2I, jstring, jint);
JNI_EXPORT(jboolean, isRunning);
JNI_EXPORT(jboolean, isMultiplayerGame);
JNI_EXPORT(void, setAction, jdoubleArray);
JNI_EXPORT(void, advanceAction__);
JNI_EXPORT(void, advanceAction__I, jint);
Expand Down
1 change: 1 addition & 0 deletions src/lib_java/java_classes/DoomGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public DoomGame(){
public native void replayEpisode(String file, int player);

public native boolean isRunning();
public native boolean isMultiplayerGame();

public native void setAction(double[] actions);
public native void advanceAction();
Expand Down
5 changes: 5 additions & 0 deletions src/lib_lua/ViZDoomLuaModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ extern "C" int luaopen_vizdoom(lua_State *luaState){
CLASS_FUNC_2_LUA(DoomGameLua, init)
CLASS_FUNC_2_LUA(DoomGameLua, loadConfig)
CLASS_FUNC_2_LUA(DoomGameLua, close)
CLASS_FUNC_2_LUA(DoomGameLua, isRunning)
CLASS_FUNC_2_LUA(DoomGameLua, isMultiplayerGame)
.def("newEpisode", &DoomGameLua::newEpisode_)
.def("newEpisode", &DoomGameLua::newEpisode_str)
.def("replayEpisode", &DoomGameLua::replayEpisode_str)
Expand Down Expand Up @@ -475,8 +477,11 @@ extern "C" int luaopen_vizdoom(lua_State *luaState){
CLASS_FUNC_2_LUA(DoomGameLua, setScreenResolution)
CLASS_FUNC_2_LUA(DoomGameLua, setScreenFormat)

CLASS_FUNC_2_LUA(DoomGameLua, isDepthBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, setDepthBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, isLabelsBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, setLabelsBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, isAutomapBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, setAutomapBufferEnabled)
CLASS_FUNC_2_LUA(DoomGameLua, setAutomapMode)
CLASS_FUNC_2_LUA(DoomGameLua, setAutomapRotate)
Expand Down
5 changes: 5 additions & 0 deletions src/lib_python/ViZDoomPythonModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ BOOST_PYTHON_MODULE(vizdoom)
.def("init", &DoomGamePython::init)
.def("load_config", &DoomGamePython::loadConfig)
.def("close", &DoomGamePython::close)
.def("is_running", &DoomGamePython::isRunning)
.def("is_multiplayer_game", &DoomGamePython::isMultiplayerGame)
.def("new_episode", newEpisode)
.def("new_episode", newEpisode_str)
.def("replay_episode", replayEpisode_default, replayEpisode_overloads())
Expand Down Expand Up @@ -498,8 +500,11 @@ BOOST_PYTHON_MODULE(vizdoom)
.def("set_screen_resolution", &DoomGamePython::setScreenResolution)
.def("set_screen_format", &DoomGamePython::setScreenFormat)

.def("is_depth_buffer_enabled", &DoomGamePython::isDepthBufferEnabled)
.def("set_depth_buffer_enabled", &DoomGamePython::setDepthBufferEnabled)
.def("is_labels_buffer_enabled", &DoomGamePython::isLabelsBufferEnabled)
.def("set_labels_buffer_enabled", &DoomGamePython::setLabelsBufferEnabled)
.def("is_automap_buffer_enabled", &DoomGamePython::isAutomapBufferEnabled)
.def("set_automap_buffer_enabled", &DoomGamePython::setAutomapBufferEnabled)
.def("set_automap_mode", &DoomGamePython::setAutomapMode)
.def("set_automap_rotate", &DoomGamePython::setAutomapRotate)
Expand Down

0 comments on commit 4c45029

Please sign in to comment.