Commit f34b34f
authored
[pgx] Add remaining native PGX environments (#411)
## Description
Add native C++ EnvPool implementations for the remaining non-MinAtar PGX
2.6.0 environments under `envpool/pgx`.
This PR adds native runtimes and bindings for TicTacToe, ConnectFour,
Hex, Othello, Kuhn Poker, Leduc Holdem, 2048, Animal Shogi, Backgammon,
Chess, Gardner Chess, Shogi, and Sparrow Mahjong. Go and the
Chinese-rule Go variants remain in the same PGX family. MinAtar is
intentionally not registered because EnvPool already has native Atari
environments.
The PR also expands PGX tests so the registered envs have smoke
coverage, deterministic rollout coverage, render coverage, and PGX
oracle alignment. Oracle alignment uses exact
`np.testing.assert_array_equal` comparisons for observations, legal
masks, rewards, done flags, and exposed state/info on tested rollouts.
Render tests validate EnvPool native RGB render determinism and shape;
they do not claim bitwise parity with PGX SVG visualizers.
Validation run:
- `bazel test --test_output=errors //envpool/pgx/...`
- `ruff format --check envpool/pgx/__init__.py
envpool/pgx/registration.py envpool/pgx/pgx_align_test.py
envpool/pgx/pgx_deterministic_test.py envpool/pgx/pgx_render_test.py
envpool/pgx/pgx_test.py`
- `ruff check envpool/pgx/__init__.py envpool/pgx/registration.py
envpool/pgx/pgx_align_test.py envpool/pgx/pgx_deterministic_test.py
envpool/pgx/pgx_render_test.py envpool/pgx/pgx_test.py`
- `clang-format --dry-run --Werror envpool/pgx/pgx.cc
envpool/pgx/animal_shogi.h envpool/pgx/backgammon.h
envpool/pgx/board_games.h envpool/pgx/card_games.h
envpool/pgx/chess_games.h envpool/pgx/play2048.h envpool/pgx/shogi.h
envpool/pgx/sparrow_mahjong.h`
- `buildifier -mode=check envpool/pgx/BUILD`
- `git diff --check`
## Motivation and Context
This completes the PGX family integration after the Go PR by registering
the remaining PGX tasks that do not overlap EnvPool's Atari support. It
keeps task IDs in EnvPool style without a `PGX` prefix and keeps the PGX
code under `envpool/pgx` instead of introducing a new JAX env folder.
- [ ] I have raised an issue to propose this change
([required](https://envpool.readthedocs.io/en/latest/pages/contributing.html)
for new features and bug fixes)
## Types of changes
What types of changes does your code introduce? Put an `x` in all the
boxes that apply:
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds core functionality)
- [x] New environment (non-breaking change which adds 3rd-party
environment)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation (update in the documentation)
- [ ] Example (update in the folder of example)
## Implemented Tasks
- [x] Add native C++ PGX runtimes and pybind registration for the
remaining non-MinAtar PGX tasks
- [x] Add smoke, deterministic, render, and exact PGX oracle alignment
tests
- [x] Update PGX docs while keeping README's supported-env list at
family granularity
## Checklist
Go over all the following points, and put an `x` in all the boxes that
apply.
If you are unsure about any of these, don't hesitate to ask. We are here
to help!
- [x] I have read the
[CONTRIBUTION](https://envpool.readthedocs.io/en/latest/pages/contributing.html)
guide (**required**)
- [x] My change requires a change to the documentation.
- [x] I have updated the tests accordingly (*required for a bug fix or a
new feature*).
- [x] I have updated the documentation accordingly.
- [ ] I have reformatted the code using `make format` (**required**)
- [ ] I have checked the code using `make lint` (**required**)
- [ ] I have ensured `make bazel-test` pass. (**required**)1 parent 0800e08 commit f34b34f
20 files changed
Lines changed: 7232 additions & 84 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
8 | 40 | | |
9 | 41 | | |
10 | | - | |
11 | | - | |
12 | 42 | | |
13 | | - | |
14 | | - | |
| 43 | + | |
15 | 44 | | |
16 | 45 | | |
17 | 46 | | |
| |||
22 | 51 | | |
23 | 52 | | |
24 | 53 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 54 | + | |
46 | 55 | | |
47 | | - | |
48 | | - | |
| 56 | + | |
| 57 | + | |
49 | 58 | | |
50 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
51 | 63 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | 37 | | |
| |||
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
35 | | - | |
| 45 | + | |
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| |||
68 | 78 | | |
69 | 79 | | |
70 | 80 | | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
19 | 48 | | |
20 | 49 | | |
21 | 50 | | |
22 | 51 | | |
23 | 52 | | |
24 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
25 | 119 | | |
26 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
27 | 136 | | |
28 | 137 | | |
29 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
30 | 163 | | |
0 commit comments