Skip to content

Commit 2750686

Browse files
Update Atari Vector documentations (#616)
1 parent df822b9 commit 2750686

8 files changed

Lines changed: 51 additions & 33 deletions

File tree

.github/workflows/build-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.9'
22+
python-version: '3.12'
2323

2424
- name: Install dependencies
2525
run: pip install -r docs/requirements.txt

.github/workflows/docs-manual-versioning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- uses: actions/setup-python@v5
3535
with:
36-
python-version: '3.9'
36+
python-version: '3.12'
3737

3838
- name: Install dependencies
3939
run: pip install -r docs/requirements.txt

.github/workflows/docs-versioning.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- uses: actions/setup-python@v5
2020
with:
21-
python-version: '3.9'
21+
python-version: '3.12'
2222

2323
- name: Get tag
2424
id: tag

.github/workflows/pypi.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
include:
2020
- runs-on: ubuntu-latest
2121
arch: x86_64
22+
- runs-on: ubuntu-24.04-arm
23+
arch: aarch64
2224
- runs-on: windows-latest
2325
arch: AMD64
2426
- runs-on: macos-13
@@ -43,27 +45,11 @@ jobs:
4345
uses: docker/build-push-action@v6
4446
with:
4547
context: .
46-
file: .github/docker/manylinux-x86_64-vcpkg.Dockerfile
47-
tags: manylinux-vcpkg:latest
48+
file: ".github/docker/manylinux-${{ matrix.arch }}-vcpkg.Dockerfile"
49+
tags: "manylinux-${{ matrix.arch }}-vcpkg:latest"
4850
push: false
4951
load: true
5052

51-
- uses: microsoft/setup-msbuild@v2
52-
if: runner.os == 'Windows'
53-
# TODO(jfarebro): 02/16/2023 - There's a bug where pkg-config isn't installed on the macOS
54-
# runner. See: https://github.com/actions/runner-images/pull/7125
55-
- name: Install pkg-config on macOS
56-
if: runner.os == 'macOS'
57-
run: brew install pkg-config
58-
59-
- uses: lukka/run-vcpkg@v11
60-
if: runner.os != 'linux'
61-
with:
62-
vcpkgGitCommitId: "8150939b69720adc475461978e07c2d2bf5fb76e"
63-
# There's a permissions issue with the cache
64-
# https://github.com/microsoft/vcpkg/issues/20121
65-
doNotCache: true
66-
6753
- name: Download and unpack ROMs
6854
run: ./scripts/download_unpack_roms.sh
6955

@@ -104,6 +90,11 @@ jobs:
10490
name: wheels-ubuntu-latest-x86_64
10591
path: dist
10692

93+
- uses: actions/download-artifact@v4
94+
with:
95+
name: wheels-ubuntu-24.04-arm-aarch64
96+
path: dist
97+
10798
- uses: actions/download-artifact@v4
10899
with:
109100
name: wheels-macos-13-x86_64

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
# args:
2626
# - --ignore-words-list=
2727
- repo: https://github.com/PyCQA/flake8
28-
rev: 7.1.1
28+
rev: 7.2.0
2929
hooks:
3030
- id: flake8
3131
args:
@@ -36,17 +36,17 @@ repos:
3636
- --show-source
3737
- --statistics
3838
- repo: https://github.com/asottile/pyupgrade
39-
rev: v3.19.0
39+
rev: v3.20.0
4040
hooks:
4141
- id: pyupgrade
4242
args: ["--py39-plus"]
4343
- repo: https://github.com/PyCQA/isort
44-
rev: 5.13.2
44+
rev: 6.0.1
4545
hooks:
4646
- id: isort
4747
args: ["--profile", "black"]
4848
- repo: https://github.com/python/black
49-
rev: 24.10.0
49+
rev: 25.1.0
5050
hooks:
5151
- id: black
5252
- repo: https://github.com/pycqa/pydocstyle

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Features
2323
- Multi-platform code (compiled and tested under macOS, Windows, and several Linux distributions).
2424
- Python bindings through [pybind11](https://github.com/pybind/pybind11).
2525
- Native support for [Gymnasium](http://github.com/farama-Foundation/gymnasium), a maintained fork of OpenAI Gym.
26-
- Visualization tools.
27-
- Atari roms are packaged within the pip package
26+
- C++ based vectorizer for acting in multiple ROMs at the same time.
27+
- Atari roms are packaged within the pip package.
2828

2929
Quick Start
3030
===========
@@ -81,6 +81,9 @@ env = gym.make('ALE/Breakout-v5', continuous=True, render_mode="human")
8181

8282
For all the environments available and their description, see [gymnasium atari page](https://gymnasium.farama.org/environments/atari/).
8383

84+
A vectorized environment with preprocessing, written in C++, is also available with `gym.make_vec("ALE/Breakout-v5", num_envs=10)`.
85+
See [vector-environment](https://ale.farama.org/vector-environment/) for more information.
86+
8487
C++
8588
---
8689

docs/vector-environment.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,28 @@
44

55
The Arcade Learning Environment (ALE) Vector Environment provides a high-performance implementation for running multiple Atari environments in parallel. This implementation utilizes native C++ code with multi-threading to achieve significant performance improvements, especially when running many environments simultaneously.
66

7-
The vector environment is equivalent to `FrameStackObservation(AtariPreprocessing(gym.make("ALE/{AtariGame}-v5")), stack_size=4)`.
7+
The vector environment is equivalent to FrameStackObservation + AtariPreprocessing from Gymnasium as
8+
```
9+
gym_envs = gym.vector.SyncVectorEnv(
10+
[
11+
lambda: gym.wrappers.FrameStackObservation(
12+
gym.wrappers.AtariPreprocessing(
13+
gym.make(env_id, frameskip=1),
14+
),
15+
stack_size=stack_num,
16+
padding_type="zero",
17+
)
18+
for _ in range(num_envs)
19+
],
20+
)
21+
ale_envs = gym.make_vec(
22+
env_id,
23+
num_envs,
24+
use_fire_reset=False,
25+
reward_clipping=False,
26+
repeat_action_probability=0.0,
27+
)
28+
```
829

930
## Key Features
1031

@@ -19,7 +40,7 @@ The vector environment is equivalent to `FrameStackObservation(AtariPreprocessin
1940
- Episodic life modes
2041
- **Performance Optimizations**:
2142
- Native C++ implementation
22-
- Next-step autoreset (see [blog](https://farama.org/Vector-Autoreset-Mode) for more detail)
43+
- Same-step and Next-step autoreset (see [blog](https://farama.org/Vector-Autoreset-Mode) for more detail)
2344
- Multi-threading for parallel execution
2445
- Thread affinity options for better performance on multi-core systems
2546
- Batch processing capabilities
@@ -41,7 +62,7 @@ from ale_py.vector_env import VectorAtariEnv
4162

4263
# Create a vector environment with 4 parallel instances of Breakout
4364
envs = VectorAtariEnv(
44-
game="breakout", # The ROM id not name, i.e., camel case compared to Gymnasium.make name versions
65+
game="breakout", # The ROM id not name, i.e., camel case compared to `gymnasium.make` name versions
4566
num_envs=4,
4667
)
4768

@@ -73,20 +94,24 @@ envs = VectorAtariEnv(
7394
img_height=84, # Height to resize frames to
7495
img_width=84, # Width to resize frames to
7596
maxpool=True, # If to maxpool sequential frames
97+
reward_clipping=True, # If to clip environment step rewards between -1 and 1
7698

7799
# Environment behavior
78100
noop_max=30, # Maximum number of no-ops at reset
79101
fire_reset=True, # Press FIRE on reset for games that require it
80102
episodic_life=False, # End episodes on life loss
103+
life_loss_info=False, # Return termination signal on life loss but don't reset the environment until all lives are alot. If used, this MUST be indicated as has a significant impact on training performance.
81104
max_episode_steps=108000, # Max frames per episode (27000 steps * 4 frame skip)
82105
repeat_action_probability=0.0, # Sticky actions probability
83106
full_action_space=False, # Use full action space (not minimal)
107+
continuous=False, # If to use continuous actions
108+
continuous_action_threshold=0.5, # The threshold at which to use continuous actions
84109

85110
# Performance options
86111
batch_size=0, # Number of environments to process at once (default=0 is the `num_envs`)
112+
autoreset_mode=gym.vector.AutoresetMode.NEXT_STEP, # How reset sub-environments when they terminated (https://farama.org/Vector-Autoreset-Mode)
87113
num_threads=0, # Number of worker threads (0=auto)
88114
thread_affinity_offset=-1,# CPU core offset for thread affinity (-1=no affinity)
89-
seed=0, # Random seed
90115
)
91116
```
92117

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ classifiers = [
3838
dependencies = [
3939
"numpy>1.20",
4040
"importlib-metadata>=4.10.0; python_version < '3.10'",
41-
"importlib-resources; python_version < '3.9'",
4241
"typing-extensions; python_version < '3.11'"
4342
]
4443
dynamic = ["version"]
@@ -72,7 +71,7 @@ packages = [
7271
"ale_py.roms",
7372
]
7473
package-dir = {ale_py = "src/ale/python"}
75-
package-data = {"ale_py" = ["py.typed", "*.py", "*.pyi", "**/*.pyi"], "ale_py.roms" = ["md5.json", "*.bin"]}
74+
package-data = {"ale_py" = ["py.typed", "*.pyi", "**/*.pyi"], "ale_py.roms" = ["md5.json", "*.bin"]}
7675

7776
[tool.pytest.ini_options]
7877
minversion = "7.0"

0 commit comments

Comments
 (0)