Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a2c6225
add the .dockerignore file
AlirezaShamsoshoara Nov 21, 2025
1bc2c00
add the readme file
AlirezaShamsoshoara Nov 21, 2025
791b46f
add the init for the doom
AlirezaShamsoshoara Nov 19, 2025
45e99e3
add the uv.lock
AlirezaShamsoshoara Nov 14, 2025
0b754bb
add the client code
AlirezaShamsoshoara Nov 22, 2025
9ff9988
add the model
AlirezaShamsoshoara Nov 21, 2025
5f86fd5
add the openenv yaml file to doom env
AlirezaShamsoshoara Nov 21, 2025
602ea5a
add the pyproject toml file for doom
AlirezaShamsoshoara Nov 21, 2025
a198cf8
add the DockerFile for Doom server
AlirezaShamsoshoara Nov 21, 2025
85b6dae
add the doom env environment to the server path
AlirezaShamsoshoara Nov 21, 2025
142c921
add the app for the server
AlirezaShamsoshoara Nov 21, 2025
caf9358
add the init for the server - Doom
AlirezaShamsoshoara Nov 21, 2025
1d4ce86
add the example to the doom
AlirezaShamsoshoara Nov 21, 2025
d3c4a2b
add vizdoom.ini to gitignore
AlirezaShamsoshoara Nov 23, 2025
74d9825
give the opportunity to the user to be able to render the observation
AlirezaShamsoshoara Nov 24, 2025
351bbaf
update the README for the new docker format
AlirezaShamsoshoara Nov 23, 2025
c5ad51a
update the Dockerfile
AlirezaShamsoshoara Nov 24, 2025
55cdb2d
add the requirements for the server to install them in the docker image
AlirezaShamsoshoara Nov 24, 2025
7071952
add the doom slayer drawing
AlirezaShamsoshoara Nov 24, 2025
1b17ec4
a code to generate gifs to cover default scnearios
AlirezaShamsoshoara Nov 24, 2025
e66f1de
add all gifs to the assets
AlirezaShamsoshoara Nov 24, 2025
e5c939e
add the gifs to top of the README file
AlirezaShamsoshoara Nov 24, 2025
3ca8ba9
update gif files and the project structure in README
AlirezaShamsoshoara Nov 24, 2025
08a6eb1
add two more gifs for symmetric view on README
AlirezaShamsoshoara Nov 24, 2025
92c96ab
move the example from the root of env to the example folder
AlirezaShamsoshoara Nov 24, 2025
faf6bdc
fix relative path issue for importing
AlirezaShamsoshoara Nov 24, 2025
d8b0fab
update pyproject.toml to consider standard for uvicorn
AlirezaShamsoshoara Nov 25, 2025
5ae10c5
fix the issue of the _step_payload that it cannot serialize to json p…
AlirezaShamsoshoara Nov 26, 2025
cd7292b
support the visualization when running the docker
AlirezaShamsoshoara Nov 25, 2025
3aa48bd
fix the issue of wrong visualization resolution for the docker run
AlirezaShamsoshoara Nov 25, 2025
fc3a9d5
update the usage for the doom visualizer file
AlirezaShamsoshoara Nov 25, 2025
8a22dce
add doomenv to the docker build yaml
AlirezaShamsoshoara Nov 26, 2025
6fac432
add the doom.md to the doc path
AlirezaShamsoshoara Nov 25, 2025
cb35e3d
update the lock and app to be compatible with openenv docker push and…
AlirezaShamsoshoara Nov 25, 2025
dec7e6c
fix the color issue in readme for openenv push feature
AlirezaShamsoshoara Nov 25, 2025
03aaf74
update the dockerfile to fix the issue of relative path
AlirezaShamsoshoara Nov 27, 2025
e6eeb6f
add the environment card for the doom_env in the doc environments
AlirezaShamsoshoara Nov 26, 2025
046e4b4
add doom guy drawing
AlirezaShamsoshoara Nov 26, 2025
5a0cf44
resize the image and align to the center via html
AlirezaShamsoshoara Nov 27, 2025
6e0cf9c
align the project structure
AlirezaShamsoshoara Nov 26, 2025
f45dd98
update the README file to include the HF OpenEnv space for Doom-env
AlirezaShamsoshoara Nov 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@ jobs:
dockerfile: src/envs/atari_env/server/Dockerfile
- name: git-env
dockerfile: src/envs/git_env/server/Dockerfile
- name: my-env # Add your environment here
- name: connect4-env # Add your environment here
dockerfile: src/envs/connect4_env/server/Dockerfile
- name: textarena-env
dockerfile: src/envs/textarena_env/server/Dockerfile
- name: browsergym-env
dockerfile: src/envs/browsergym_env/server/Dockerfile
- name: snake-env
dockerfile: src/envs/snake_env/server/Dockerfile
- name: doom-env
dockerfile: src/envs/doom_env/server/Dockerfile

steps:
- name: Checkout code
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,8 @@ outputs/
/uv.lock
.uv/

# ViZDoom generated files
**/_vizdoom.ini
_vizdoom.ini

*.backup*/
19 changes: 19 additions & 0 deletions docs/environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ The OpenEnv community has built a catalog of ready-to-run environments that cove
</div>
</div>

<div class="environment-card">
<div class="environment-card__body">
<span class="environment-card__tag">Doom</span>
<p class="environment-card__description">
ViZDoom-powered 3D environment for visual RL research with multiple scenarios, configurable resolution, and real-time rendering.
</p>
</div>
<div class="environment-card__links">
<a class="environment-card__icon" href="/OpenEnv/environments/doom/" aria-label="Doom docs">
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
<path d="M6 3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V9l-6-6H6zm8 1.5L18.5 9H14V4.5z" fill="currentColor"/>
</svg>
</a>
<a class="environment-card__icon environment-card__icon--hf" href="https://huggingface.co/spaces/Crashbandicoote2/doom_env" target="_blank" rel="noreferrer noopener" aria-label="Doom on Hugging Face">
<img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" alt="" aria-hidden="true" />
</a>
</div>
</div>

</div>

> Want to publish your own environment? Head over to the [Build Your Own Environment](environment-builder.md) guide for a step-by-step walkthrough.
1 change: 1 addition & 0 deletions docs/environments/doom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--8<-- "../../src/envs/doom_env/README.md"
245 changes: 245 additions & 0 deletions examples/doom_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""
Example usage of the Doom Environment.

This script demonstrates how to use the Doom environment with OpenEnv.
It can be run in two modes:
1. With Docker: Uses the Docker image to run the environment
2. Local: Directly uses the DoomEnvironment class (requires ViZDoom installed)

Both modes support rendering if the appropriate libraries are installed.
"""

import argparse
import sys
import time
from pathlib import Path

import numpy as np

# Add src to path
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))


def run_with_docker(render: bool = False, num_steps: int = 100):
"""Run Doom environment using Docker container."""
from envs.doom_env import DoomAction, DoomEnv

print("Starting Doom environment with Docker...")
try:
# Create environment from Docker image
env = DoomEnv.from_docker_image("doom-env:latest")

# Reset to start a new episode
result = env.reset()
print(f"✓ Environment reset")
print(f" Screen shape: {result.observation.screen_shape}")
print(f" Available actions: {result.observation.available_actions}")
print(f" Game variables: {result.observation.game_variables}")

if render:
print(f"\n✓ Rendering enabled")
print(f" Note: Rendering uses the observation from the server")
print(
f" For best performance, consider using local mode with window_visible=True"
)
print(f" Alternative: Use the web interface at http://localhost:8000/web")
print(
f" Make sure opencv-python or matplotlib is installed locally for rendering"
)

# Run for a few steps
print(f"\nRunning episode for {num_steps} steps...")
for i in range(num_steps):
# Take a random action from available actions
available_actions = result.observation.available_actions
if available_actions:
action_id = int(
np.random.choice(available_actions)
) # Convert to Python int
else:
action_id = 0

result = env.step(DoomAction(action_id=action_id))

# Render if requested
if render:
env.render()

if i % 10 == 0 or result.observation.done:
print(f"Step {i+1}:")
print(f" Action: {action_id}")
print(f" Reward: {result.reward}")
print(f" Done: {result.observation.done}")
if result.observation.game_variables:
print(f" Game vars: {result.observation.game_variables}")

if result.observation.done:
print(f"\n✓ Episode finished at step {i+1}!")
break

# Small delay for rendering to be visible
if render:
time.sleep(0.03)

finally:
print("\nCleaning up...")
env.close()
print("✓ Environment closed")


def run_local(render: bool = False, num_steps: int = 100):
"""Run Doom environment locally without Docker."""
try:
from envs.doom_env.models import DoomAction
from envs.doom_env.server.doom_env_environment import DoomEnvironment
except ImportError as e:
print(f"Error: Could not import environment components: {e}")
print("Make sure ViZDoom is installed: pip install vizdoom")
return

print("Starting Doom environment locally...")
try:
# Create environment
# Note: When using local mode, you can enable window_visible=True
# for native ViZDoom rendering (most efficient)
env = DoomEnvironment(
scenario="basic",
screen_resolution="RES_320X240", # Higher resolution for better visibility
screen_format="RGB24",
window_visible=render, # Use native ViZDoom window if rendering
use_discrete_actions=True,
)

# Reset to start a new episode
obs = env.reset()
print(f"✓ Environment reset")
print(f" Screen shape: {obs.screen_shape}")
print(f" Available actions: {obs.available_actions}")
print(f" Game variables: {obs.game_variables}")

if render:
print(f"\n✓ Rendering enabled")
if env.window_visible:
print(f" Using native ViZDoom window (most efficient)")
else:
print(f" Using Python rendering (cv2/matplotlib)")

# Run for a few steps
print(f"\nRunning episode for {num_steps} steps...")
for i in range(num_steps):
# Take a random action
if obs.available_actions:
action_id = int(
np.random.choice(obs.available_actions)
) # Convert to Python int
else:
action_id = 0

obs = env.step(DoomAction(action_id=action_id))

# Render if requested and not using native window
if render and not env.window_visible:
env.render()

if i % 10 == 0 or obs.done:
print(f"Step {i+1}:")
print(f" Action: {action_id}")
print(f" Reward: {obs.reward}")
print(f" Done: {obs.done}")
if obs.game_variables:
print(f" Game vars: {obs.game_variables}")

if obs.done:
print(f"\n✓ Episode finished at step {i+1}!")
break

# Small delay for rendering to be visible
if render:
time.sleep(0.03)

# Visualize final frame statistics
if not obs.done:
screen = np.array(obs.screen_buffer).reshape(obs.screen_shape)
print(f"\nFinal screen statistics:")
print(f" Shape: {screen.shape}")
print(f" Dtype: {screen.dtype}")
print(f" Min: {screen.min()}, Max: {screen.max()}")

except Exception as e:
print(f"Error running environment: {e}")
import traceback

traceback.print_exc()
finally:
if "env" in locals():
env.close()
print("✓ Environment closed")


def main():
"""Main entry point."""
parser = argparse.ArgumentParser(
description="Run Doom environment example",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Run with Docker (default)
python example.py

# Run with Docker and rendering
python example.py --render

# Run locally without Docker
python example.py --local

# Run locally with rendering (uses native ViZDoom window)
python example.py --local --render

# Run for more steps
python example.py --local --render --steps 300

Note: Rendering requires opencv-python or matplotlib:
pip install opencv-python
# or
pip install matplotlib
""",
)
parser.add_argument(
"--docker", action="store_true", default=False, help="Run with Docker container"
)
parser.add_argument(
"--local", action="store_true", help="Run locally without Docker"
)
parser.add_argument(
"--render",
action="store_true",
help="Enable rendering (shows game window or visualization)",
)
parser.add_argument(
"--steps",
type=int,
default=100,
help="Number of steps to run (default: 100)",
)

args = parser.parse_args()

# Default to docker if neither specified
if not args.local and not args.docker:
args.docker = True

if args.local:
run_local(render=args.render, num_steps=args.steps)
else:
run_with_docker(render=args.render, num_steps=args.steps)


if __name__ == "__main__":
main()
Loading