Skip to content

Commit e1f7c44

Browse files
authored
Merge pull request Farama-Foundation#564 from Farama-Foundation/docs-update
Improve the documentation regarding scenarios/enviroments
2 parents dd603d8 + 44c79e9 commit e1f7c44

11 files changed

+119
-218
lines changed

docs/environments/creatingCustom.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Creating a custom environment
22

3-
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.
3+
ViZDoom allows the use 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 you to create a map used by the environment and program custom logic and rewards using ACS scripting language. In addition to a map+script created in one of the editors that is 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.
44

55

66
## Limitations and possibilities
@@ -10,8 +10,8 @@ Before we start explaining the process of creating custom environments, one ques
1010
- **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.
1111
- **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.
1212
- **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.
13-
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.
14-
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.
13+
It has a simple C-like syntax and is very powerful. It allows you to create custom game rules and rewards. It has a large number of functions that allow the modification/extension of 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.
14+
Due to the engine's architecture, the only area that ACS is a bit lacking is the possibility of modifying map geometry. Simple modifications are possible (like changing the height of some part of the level to create elevators or doors), 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.
1515
- **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:
1616
- possibility to define actions space
1717
- possibility to define what is included in the observation (types of buffers, additional variables, etc.)
@@ -25,9 +25,9 @@ Due to the engine's architecture, the only area that ACS is a bit lacking is the
2525

2626
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.
2727

28-
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.
28+
When creating a new map, select UDMF format for maps. If asked for a node builder, you can select none, as ViZDoom has it built in. 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.
2929

30-
You can add some custom ACS scripts to your map. This ACS script allows to add implement a rewarding mechanism.
30+
You can add some custom ACS scripts to your map. This ACS script allows the implementation of a rewarding mechanism.
3131
To do that, you need to employ the global variable 0 like this:
3232

3333
```{code-block} C
@@ -43,13 +43,13 @@ script 1(void)
4343

4444
The global variable 0 will be used by ViZDoom to get the reward value.
4545

46-
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.
47-
ViZDoom treats the reward as a fixed point numeral, so you always need to use decimal points in ACS scripts.
46+
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. Please be aware of that difference. ViZDoom treats the reward as a fixed point numeral, so you always need to use decimal points in ACS scripts.
47+
Unfortunately, ACS does not support real floating point numbers.
4848

4949

5050
## Step 2: Creating a custom config file
5151

52-
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).
52+
After creating a map, it is a good idea to create an accompanying config file, that allows to easily define action space, available information in a state/observation, additional rewards, etc. The config file is a simple text file in an *.ini-like format that can be created using any text editor. The config files are documented under [api/configurationFiles.md](api/configurationFiles.md).
5353

5454
The following is an example of a config file that can be used with the map created in the previous step:
5555

docs/environments/default.md

+91-21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
# Default scenarios/environments
22

3-
Below we describe all default scenarios (original ViZDoom nomenclature)/environments (Gymnasium/Open AI Gym nomenclature) included with ViZDoom. The PRs with new scenarios are welcome!
3+
Below we describe a default singleplayer scenarios (original ViZDoom nomenclature)/environments (Gymnasium/Open AI Gym nomenclature) included with ViZDoom. The PRs with new scenarios are welcome!
4+
5+
6+
## How to use default scenarios
7+
8+
When using original ViZDoom API, each scenario can be loaded [`load_config`](../api/python/doomGame.md#vizdoom.DoomGame.load_config) (Python)/[`loadConfig`](../api/cpp/doomGame.md#loadconfig) (C++) method:
9+
10+
Python example:
11+
```{code-block} python
12+
import os
13+
import vizdoom as vzd
14+
game = vzd.DoomGame()
15+
game.load_config(os.path.join(vzd.scenarios_path, "basic.cfg")) # or any other scenario file
16+
```
17+
18+
When using Gymnasium (or Gym) API the scenario can be loaded by passing the scenario id to `make` method like-this:
19+
20+
```{code-block} python
21+
import gymnasium
22+
from vizdoom import gymnasium_wrapper # This import will register all the environments
23+
24+
env = gymnasium.make("VizdoomBasic-v0") # or any other environment id
25+
```
26+
427

528

629
## Note on .wad, .cfg files, and rewards
730

8-
The scenarios consist of two files - .wad and .cfg ([see scenarios directory](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios)). The .wad file contains the map and script, and the .cfg file contains additional settings. The maps contained in .wad files (Doom's engine format for storing maps and assets) usually do not implement action constraints, the death penalty, and living rewards (however it is possible). To make it easier, this can be specified in ViZDoom .cfg files as well as other options like access to additional information. These can also be overridden in the code when using the original ViZDoom API. Every mention of any settings that are not included in .wad files is specified with "(config)" in the descriptions below. ViZDoom does not support setting certain rewards (such as killing opponents) in .cfg files. These must be programmed in the .wad files instead.
31+
A scenario usually consist of two files - .wad and .cfg ([see scenarios directory](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios)). The .wad file contains the map and script, and the .cfg file contains additional settings. The maps contained in .wad files (Doom's engine format for storing maps and assets) usually do not implement action constraints, the death penalty, and living rewards (however it is possible). To make it easier, this can be specified in ViZDoom .cfg files as well as other options like access to additional information. These can also be overridden in the code when using the original ViZDoom API. Every mention of any settings that are not included in .wad files is specified with "(config)" in the descriptions below. ViZDoom does not support setting certain rewards (such as killing opponents) in .cfg files. These must be programmed in the .wad files instead.
932

1033

1134
## BASIC
@@ -20,18 +43,22 @@ and shoot. 1 hit is enough to kill the monster. The episode
2043
finishes when the monster is killed or on timeout.
2144

2245
**REWARDS:**
23-
2446
* +106 for killing the monster
2547
* -5 for every shot
2648
* +1 for every tic the agent is alive
2749

2850
The episode ends after killing the monster or on timeout.
2951

3052
**CONFIGURATION:**
31-
* 3 available buttons: move left, move right, shoot (attack)
53+
* 3 available buttons: move left/right, shoot (attack)
54+
* 1 available game variable: player's ammo
3255
* timeout = 300 tics
3356

34-
Configuration file: [basic.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/basic.cfg)
57+
58+
**Gymnasium/Gym id: `"VizdoomBasic-v0"`**
59+
60+
**Configuration file: [basic.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/basic.cfg)**
61+
3562

3663
## DEADLY CORRIDOR
3764
The purpose of this scenario is to teach the agent to navigate towards
@@ -43,21 +70,45 @@ in total). A green vest is placed at the opposite end of the corridor.
4370
The reward is proportional (negative or positive) to the change in the
4471
distance between the player and the vest. If the player ignores monsters
4572
on the sides and runs straight for the vest, he will be killed somewhere
46-
along the way. To ensure this behavior doom_skill = 5 (config) is
73+
along the way. To ensure this behavior difficulty level (`doom_skill`) = 5 (config) is
4774
needed.
4875

4976
**REWARDS:**
50-
5177
* +dX for getting closer to the vest.
5278
* -dX for getting further from the vest.
5379
* -100 for death
5480

5581
**CONFIGURATION:**
56-
* 5 available buttons: turn left, turn right, move left, move right, shoot (attack)
82+
* 7 available buttons: move forward/backwward/left/right, turn left/right, shoot (attack)
83+
* 1 available game variable: player's health
84+
* timeout = 2100
85+
* difficulty level (`doom_skill`) = 5
86+
87+
**Gymnasium/Gym id: `"VizdoomCorridor-v0"`**
88+
89+
**Configuration file: [deadly_corridor.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/deadly_corridor.cfg)**
90+
91+
92+
## DEATHMATCH
93+
In this scenario, the agent is spawned in the random place of the arena filled with resources.
94+
A random monster is spawned every few seconds that will try to kill the player.
95+
The reward for killing a monster depends on its difficulty.
96+
The aim of the agent is to kill as many monsters as possible
97+
before the time runs out or it's killed by monsters.
98+
99+
**REWARDS:**
100+
* Different rewards are given for killing different monsters
101+
102+
**CONFIGURATION:**
103+
* 16 available binary buttons: move forward/backwward/left/right, turn left/right, strafe, sprint (speed), shoot (attack), select weapon 1-6/next/previous
104+
* 3 available delta buttons: look up/down, turn left/right, move left/right
105+
* 5 available game variables: player's health, armor, selected weapon and ammo, killcount
57106
* timeout = 4200
58-
* doom_skill = 5
107+
* difficulty level (`doom_skill`) = 3
59108

60-
Configuration file: [scenarios/basic.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/deadly_corridor.cfg)
109+
**Gymnasium/Gym id: `"VizdoomDeathmatch-v0"`**
110+
111+
**Configuration file: [scenarios/deathmatch.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/deathmatch.cfg)**
61112

62113

63114
## DEFEND THE CENTER
@@ -78,8 +129,13 @@ because of limited ammo).
78129

79130
**CONFIGURATION:**
80131
* 3 available buttons: turn left, turn right, shoot (attack)
132+
* 2 available game variables: player's health and ammo
133+
* timeout = 2100
134+
* difficulty level (`doom_skill`) = 3
81135

82-
Configuration file: [scenarios/defend_the_center.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/defend_the_center.cfg)
136+
**Gymnasium/Gym id: `"VizdoomDefendCenter-v0"`**
137+
138+
**Configuration file: [defend_the_center.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/defend_the_center.cfg)**
83139

84140

85141
## DEFEND THE LINE
@@ -101,8 +157,12 @@ because of limited ammo).
101157

102158
**CONFIGURATION:**
103159
* 3 available buttons: turn left, turn right, shoot (attack)
160+
* 2 available game variables: player's health and ammo
161+
* difficulty level (`doom_skill`) = 3
162+
163+
**Gymnasium/Gym id: `"VizdoomDefendLine-v0"`**
104164

105-
Configuration file: [scenarios/defend_the_line.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/defend_the_line.cfg)
165+
**Configuration file: [defend_the_line.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/defend_the_line.cfg)**
106166

107167

108168
## HEALTH GATHERING (AND HEALTH GATHERING SUPREME)
@@ -126,10 +186,12 @@ that makes map layout more complex.
126186
* -100 for death
127187

128188
**CONFIGURATION:**
129-
* 3 available buttons: turn left, turn right, move forward
130-
* 1 available game variable: HEALTH
189+
* 3 available buttons: turn left/right, move forward
190+
* 1 available game variable: player's health
131191

132-
Configuration file: [scenarios/health_gathering.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/health_gathering.cfg)/[scenarios/health_gathering_supreme.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/health_gathering_supreme.cfg)
192+
**Gymnasium/Gym id: `"VizdoomHealthGathering-v0"`/`"VizdoomHealthGatheringSupreme-v0"`**
193+
194+
**Configuration file: [health_gathering.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/health_gathering.cfg)/[health_gathering_supreme.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/health_gathering_supreme.cfg)**
133195

134196

135197
## MY WAY HOME
@@ -148,10 +210,12 @@ direction. The episode ends when the vest is reached or on timeout/
148210
* -0.0001 for every tic the agent is alive
149211

150212
**CONFIGURATION:**
151-
* 3 available buttons: turn left, turn right, move forward
213+
* 3 available buttons: turn left/right, move forward
152214
* timeout = 2100
153215

154-
Configuration file: [scenarios/my_way_home.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/my_way_home.cfg)
216+
**Gymnasium/Gym id: `"VizdoomMyWayHome-v0"`**
217+
218+
**Configuration file: [my_way_home.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/my_way_home.cfg)**
155219

156220

157221
## PREDICT POSITION
@@ -172,10 +236,12 @@ or on timeout.
172236
* -0.0001 for every tic the agent is alive
173237

174238
**CONFIGURATION:**
175-
* 3 available buttons: turn left, turn right, shoot (attack)
239+
* 3 available buttons: turn left/right, shoot (attack)
176240
* timeout = 300
177241

178-
Configuration file: [scenarios/predict_position.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/predict_position.cfg)
242+
**Gymnasium/Gym id: `"VizdoomPredictPosition-v0"`**
243+
244+
**Configuration file: [predict_position.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/predict_position.cfg)**
179245

180246

181247
## TAKE COVER
@@ -196,6 +262,10 @@ the player dies.
196262
* +1 for every tic the agent is alive
197263

198264
**CONFIGURATION:**
199-
* 2 available buttons: move left, move right
265+
* 2 available buttons: move left/right
266+
* 1 available game variable: player's health
267+
* difficulty level (`doom_skill`) = 4
268+
269+
**Gymnasium/Gym id: `"VizdoomTakeCover-v0"`**
200270

201-
Configuration file: [scenarios/take_cover.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/take_cover.cfg)
271+
**Configuration file: [take_cover.cfg](https://github.com/Farama-Foundation/ViZDoom/tree/master/scenarios/take_cover.cfg)**

0 commit comments

Comments
 (0)