cuju-engine 0.3.0__py3-none-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. cuju/__init__.py +217 -0
  2. cuju/__main__.py +262 -0
  3. cuju/_batch/__init__.py +4 -0
  4. cuju/_batch/allocator.py +52 -0
  5. cuju/_batch/assets.py +68 -0
  6. cuju/_batch/environment.py +1890 -0
  7. cuju/_batch/frame_stack.py +114 -0
  8. cuju/_batch/library.py +190 -0
  9. cuju/_batch/log.py +103 -0
  10. cuju/_batch/memory.py +70 -0
  11. cuju/_batch/operators.py +55 -0
  12. cuju/_batch/pinned.py +39 -0
  13. cuju/_batch/pixels.py +207 -0
  14. cuju/_batch/state.py +77 -0
  15. cuju/_checksums.py +60 -0
  16. cuju/_cli_contract.py +244 -0
  17. cuju/_cli_parsers.py +191 -0
  18. cuju/_completion.py +277 -0
  19. cuju/_dump_to_txt.py +66 -0
  20. cuju/_grf_config.py +331 -0
  21. cuju/_library_path.py +141 -0
  22. cuju/_media.py +113 -0
  23. cuju/_pixels.py +276 -0
  24. cuju/_plugins.py +106 -0
  25. cuju/_python_players.py +224 -0
  26. cuju/_replay_command.py +109 -0
  27. cuju/_replay_player.py +42 -0
  28. cuju/_replays.py +414 -0
  29. cuju/_script_helpers.py +109 -0
  30. cuju/_version.py +6 -0
  31. cuju/action_log.py +371 -0
  32. cuju/check.py +596 -0
  33. cuju/cuju_cpu.dll +0 -0
  34. cuju/cuju_cuda.dll +0 -0
  35. cuju/cuju_render.dll +0 -0
  36. cuju/data/SHA256SUMS +20 -0
  37. cuju/data/animations.bin +0 -0
  38. cuju/data/assets/11_vs_11_competition_l0_r0.cjb +0 -0
  39. cuju/data/assets/11_vs_11_easy_stochastic_l0_r0.cjb +0 -0
  40. cuju/data/assets/11_vs_11_hard_stochastic_l0_r0.cjb +0 -0
  41. cuju/data/assets/11_vs_11_kaggle_l0_r0.cjb +0 -0
  42. cuju/data/assets/11_vs_11_stochastic_l0_r0.cjb +0 -0
  43. cuju/data/assets/1_vs_1_easy_l0_r0.cjb +0 -0
  44. cuju/data/assets/5_vs_5_l0_r0.cjb +0 -0
  45. cuju/data/assets/academy_3_vs_1_with_keeper_l0_r0.cjb +0 -0
  46. cuju/data/assets/academy_corner_l0_r0.cjb +0 -0
  47. cuju/data/assets/academy_counterattack_easy_l0_r0.cjb +0 -0
  48. cuju/data/assets/academy_counterattack_hard_l0_r0.cjb +0 -0
  49. cuju/data/assets/academy_empty_goal_close_l0_r0.cjb +0 -0
  50. cuju/data/assets/academy_empty_goal_l0_r0.cjb +0 -0
  51. cuju/data/assets/academy_pass_and_shoot_with_keeper_l0_r0.cjb +0 -0
  52. cuju/data/assets/academy_run_pass_and_shoot_with_keeper_l0_r0.cjb +0 -0
  53. cuju/data/assets/academy_run_to_score_l0_r0.cjb +0 -0
  54. cuju/data/assets/academy_run_to_score_with_keeper_l0_r0.cjb +0 -0
  55. cuju/data/assets/academy_single_goal_versus_lazy_l0_r0.cjb +0 -0
  56. cuju/data/assets/test_example_multiagent_l0_r0.cjb +0 -0
  57. cuju/data/digests.json +186 -0
  58. cuju/data/render_digests.json.z +0 -0
  59. cuju/data/scenarios/11_vs_11_competition.py +45 -0
  60. cuju/data/scenarios/11_vs_11_easy_stochastic.py +44 -0
  61. cuju/data/scenarios/11_vs_11_hard_stochastic.py +44 -0
  62. cuju/data/scenarios/11_vs_11_kaggle.py +46 -0
  63. cuju/data/scenarios/11_vs_11_stochastic.py +44 -0
  64. cuju/data/scenarios/1_vs_1_easy.py +25 -0
  65. cuju/data/scenarios/5_vs_5.py +33 -0
  66. cuju/data/scenarios/academy_3_vs_1_with_keeper.py +28 -0
  67. cuju/data/scenarios/academy_corner.py +45 -0
  68. cuju/data/scenarios/academy_counterattack_easy.py +45 -0
  69. cuju/data/scenarios/academy_counterattack_hard.py +45 -0
  70. cuju/data/scenarios/academy_empty_goal.py +25 -0
  71. cuju/data/scenarios/academy_empty_goal_close.py +25 -0
  72. cuju/data/scenarios/academy_pass_and_shoot_with_keeper.py +27 -0
  73. cuju/data/scenarios/academy_run_pass_and_shoot_with_keeper.py +27 -0
  74. cuju/data/scenarios/academy_run_to_score.py +30 -0
  75. cuju/data/scenarios/academy_run_to_score_with_keeper.py +30 -0
  76. cuju/data/scenarios/academy_single_goal_versus_lazy.py +49 -0
  77. cuju/data/scenarios/test_example_multiagent.py +28 -0
  78. cuju/dumps.py +942 -0
  79. cuju/engine_status.py +106 -0
  80. cuju/env.py +1168 -0
  81. cuju/errors.py +108 -0
  82. cuju/gfootball/GRF_SOURCES +86 -0
  83. cuju/gfootball/__init__.py +60 -0
  84. cuju/gfootball/_cv2.py +43 -0
  85. cuju/gfootball/_gym/__init__.py +88 -0
  86. cuju/gfootball/_gym/_vendored/GYM_SOURCES +22 -0
  87. cuju/gfootball/_gym/_vendored/__init__.py +43 -0
  88. cuju/gfootball/_gym/_vendored/core.py +361 -0
  89. cuju/gfootball/_gym/_vendored/envs/__init__.py +19 -0
  90. cuju/gfootball/_gym/_vendored/envs/registration.py +284 -0
  91. cuju/gfootball/_gym/_vendored/error.py +230 -0
  92. cuju/gfootball/_gym/_vendored/logger.py +56 -0
  93. cuju/gfootball/_gym/_vendored/spaces/__init__.py +30 -0
  94. cuju/gfootball/_gym/_vendored/spaces/box.py +171 -0
  95. cuju/gfootball/_gym/_vendored/spaces/dict.py +162 -0
  96. cuju/gfootball/_gym/_vendored/spaces/discrete.py +41 -0
  97. cuju/gfootball/_gym/_vendored/spaces/multi_binary.py +61 -0
  98. cuju/gfootball/_gym/_vendored/spaces/multi_discrete.py +77 -0
  99. cuju/gfootball/_gym/_vendored/spaces/space.py +94 -0
  100. cuju/gfootball/_gym/_vendored/spaces/tuple.py +96 -0
  101. cuju/gfootball/_gym/_vendored/spaces/utils.py +228 -0
  102. cuju/gfootball/_gym/_vendored/utils/__init__.py +13 -0
  103. cuju/gfootball/_gym/_vendored/utils/closer.py +72 -0
  104. cuju/gfootball/_gym/_vendored/utils/colorize.py +36 -0
  105. cuju/gfootball/_gym/_vendored/utils/ezpickle.py +37 -0
  106. cuju/gfootball/_gym/_vendored/utils/json_utils.py +27 -0
  107. cuju/gfootball/_gym/_vendored/utils/seeding.py +101 -0
  108. cuju/gfootball/_gym/_vendored/version.py +5 -0
  109. cuju/gfootball/_gym/_vendored/wrappers/__init__.py +8 -0
  110. cuju/gfootball/_gym/_vendored/wrappers/order_enforcing.py +20 -0
  111. cuju/gfootball/_gym/_vendored/wrappers/time_limit.py +31 -0
  112. cuju/gfootball/dump_to_txt.py +49 -0
  113. cuju/gfootball/dump_to_video.py +33 -0
  114. cuju/gfootball/env/__init__.py +271 -0
  115. cuju/gfootball/env/config.py +163 -0
  116. cuju/gfootball/env/constants.py +33 -0
  117. cuju/gfootball/env/controller_base.py +114 -0
  118. cuju/gfootball/env/event_queue.py +54 -0
  119. cuju/gfootball/env/football_action_set.py +220 -0
  120. cuju/gfootball/env/football_action_set_test.py +76 -0
  121. cuju/gfootball/env/football_env.py +225 -0
  122. cuju/gfootball/env/football_env_core.py +447 -0
  123. cuju/gfootball/env/football_env_test.py +692 -0
  124. cuju/gfootball/env/gym_test.py +47 -0
  125. cuju/gfootball/env/observation_preprocessing.py +94 -0
  126. cuju/gfootball/env/observation_processor.py +526 -0
  127. cuju/gfootball/env/observation_rotation.py +163 -0
  128. cuju/gfootball/env/observation_rotation_test.py +84 -0
  129. cuju/gfootball/env/player_base.py +46 -0
  130. cuju/gfootball/env/players/__init__.py +16 -0
  131. cuju/gfootball/env/players/agent.py +39 -0
  132. cuju/gfootball/env/players/bot.py +217 -0
  133. cuju/gfootball/env/players/gamepad.py +81 -0
  134. cuju/gfootball/env/players/keyboard.py +72 -0
  135. cuju/gfootball/env/players/lazy.py +31 -0
  136. cuju/gfootball/env/players/ppo2_cnn.py +119 -0
  137. cuju/gfootball/env/players/replay.py +40 -0
  138. cuju/gfootball/env/remote_football_env.py +189 -0
  139. cuju/gfootball/env/scenario_builder.py +125 -0
  140. cuju/gfootball/env/script_helpers.py +130 -0
  141. cuju/gfootball/env/script_helpers_test.py +107 -0
  142. cuju/gfootball/env/wrappers.py +440 -0
  143. cuju/gfootball/env/wrappers_test.py +150 -0
  144. cuju/gfootball/eval_server/__init__.py +17 -0
  145. cuju/gfootball/eval_server/config.py +30 -0
  146. cuju/gfootball/eval_server/example_client.py +107 -0
  147. cuju/gfootball/eval_server/proto/game_server.proto +62 -0
  148. cuju/gfootball/eval_server/proto/game_server_pb2.py +501 -0
  149. cuju/gfootball/eval_server/proto/game_server_pb2_grpc.py +113 -0
  150. cuju/gfootball/eval_server/proto/master.proto +25 -0
  151. cuju/gfootball/eval_server/proto/master_pb2.py +184 -0
  152. cuju/gfootball/eval_server/proto/master_pb2_grpc.py +62 -0
  153. cuju/gfootball/eval_server/utils.py +52 -0
  154. cuju/gfootball/examples/__init__.py +16 -0
  155. cuju/gfootball/examples/models.py +66 -0
  156. cuju/gfootball/examples/run_multiagent_rllib.py +140 -0
  157. cuju/gfootball/examples/run_ppo2.py +123 -0
  158. cuju/gfootball/play_game.py +73 -0
  159. cuju/gfootball/replay.py +43 -0
  160. cuju/gfootball/scenarios/11_vs_11_competition.py +59 -0
  161. cuju/gfootball/scenarios/11_vs_11_easy_stochastic.py +57 -0
  162. cuju/gfootball/scenarios/11_vs_11_hard_stochastic.py +57 -0
  163. cuju/gfootball/scenarios/11_vs_11_kaggle.py +60 -0
  164. cuju/gfootball/scenarios/11_vs_11_stochastic.py +57 -0
  165. cuju/gfootball/scenarios/1_vs_1_easy.py +39 -0
  166. cuju/gfootball/scenarios/5_vs_5.py +46 -0
  167. cuju/gfootball/scenarios/__init__.py +31 -0
  168. cuju/gfootball/scenarios/academy_3_vs_1_with_keeper.py +42 -0
  169. cuju/gfootball/scenarios/academy_corner.py +59 -0
  170. cuju/gfootball/scenarios/academy_counterattack_easy.py +59 -0
  171. cuju/gfootball/scenarios/academy_counterattack_hard.py +59 -0
  172. cuju/gfootball/scenarios/academy_empty_goal.py +39 -0
  173. cuju/gfootball/scenarios/academy_empty_goal_close.py +39 -0
  174. cuju/gfootball/scenarios/academy_pass_and_shoot_with_keeper.py +41 -0
  175. cuju/gfootball/scenarios/academy_run_pass_and_shoot_with_keeper.py +41 -0
  176. cuju/gfootball/scenarios/academy_run_to_score.py +44 -0
  177. cuju/gfootball/scenarios/academy_run_to_score_with_keeper.py +44 -0
  178. cuju/gfootball/scenarios/academy_single_goal_versus_lazy.py +63 -0
  179. cuju/gfootball/scenarios/test_example_multiagent.py +42 -0
  180. cuju/gfootball/scenarios/tests/11_vs_11_deterministic.py +58 -0
  181. cuju/gfootball/scenarios/tests/11_vs_11_easy_deterministic.py +58 -0
  182. cuju/gfootball/scenarios/tests/11_vs_11_hard_deterministic.py +58 -0
  183. cuju/gfootball/scenarios/tests/11_vs_11_single_goal_deterministic.py +58 -0
  184. cuju/gfootball/scenarios/tests/11_vs_11_single_goal_stochastic.py +58 -0
  185. cuju/gfootball/scenarios/tests/11_vs_4_offence_deterministic.py +47 -0
  186. cuju/gfootball/scenarios/tests/11_vs_4_offence_stochastic.py +47 -0
  187. cuju/gfootball/scenarios/tests/__init__.py +31 -0
  188. cuju/gfootball/scenarios/tests/corner_test.py +38 -0
  189. cuju/gfootball/scenarios/tests/goal_test.py +35 -0
  190. cuju/gfootball/scenarios/tests/keeper_test.py +38 -0
  191. cuju/gfootball/scenarios/tests/kickoff_for_goal_loosing_team_test.py +34 -0
  192. cuju/gfootball/scenarios/tests/multiagent_wrapper.py +60 -0
  193. cuju/gfootball/scenarios/tests/offside_test.py +39 -0
  194. cuju/gfootball/scenarios/tests/penalty.py +34 -0
  195. cuju/gfootball/scenarios/tests/second_half.py +33 -0
  196. cuju/gfootball/scenarios/tests/symmetric.py +53 -0
  197. cuju/gfootball_engine/__init__.py +31 -0
  198. cuju/gfootball_engine/_gameplayfootball.py +1624 -0
  199. cuju/gfootball_engine/_native.py +193 -0
  200. cuju/gfootball_engine/_pickle_names.py +114 -0
  201. cuju/gfootball_engine/_render_hooks.py +156 -0
  202. cuju/kaggle.py +425 -0
  203. cuju/multi_device.py +401 -0
  204. cuju/players.py +260 -0
  205. cuju/raw.py +93 -0
  206. cuju/scenarios.py +661 -0
  207. cuju/state.py +211 -0
  208. cuju/wrappers.py +325 -0
  209. cuju_engine-0.3.0.dist-info/METADATA +325 -0
  210. cuju_engine-0.3.0.dist-info/RECORD +222 -0
  211. cuju_engine-0.3.0.dist-info/WHEEL +5 -0
  212. cuju_engine-0.3.0.dist-info/entry_points.txt +4 -0
  213. cuju_engine-0.3.0.dist-info/licenses/LICENSE +202 -0
  214. cuju_engine-0.3.0.dist-info/licenses/LICENSES/BSD-3-Clause.txt +31 -0
  215. cuju_engine-0.3.0.dist-info/licenses/LICENSES/BSL-1.0.txt +23 -0
  216. cuju_engine-0.3.0.dist-info/licenses/LICENSES/LGPL-2.1-or-later.txt +502 -0
  217. cuju_engine-0.3.0.dist-info/licenses/LICENSES/MIT-Mesa.txt +26 -0
  218. cuju_engine-0.3.0.dist-info/licenses/LICENSES/MIT-gym.txt +23 -0
  219. cuju_engine-0.3.0.dist-info/licenses/LICENSES/MIT.txt +23 -0
  220. cuju_engine-0.3.0.dist-info/licenses/LICENSES/SunPro.txt +8 -0
  221. cuju_engine-0.3.0.dist-info/licenses/LICENSES/Zlib.txt +20 -0
  222. cuju_engine-0.3.0.dist-info/licenses/NOTICE +56 -0
cuju/errors.py ADDED
@@ -0,0 +1,108 @@
1
+ # Copyright 2026 The cuju Authors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """The exceptions that cuju raises, each also a subclass of the built-in type it stands for.
5
+
6
+ Every class derives from `Error` and from a built-in exception, so a clause such as
7
+ `except ValueError:` catches it as well. `ChoiceError` is also a `KeyError`, and
8
+ `EnvironmentIndexError` is both an `IndexError` and a `RuntimeError`.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ __all__ = [
14
+ 'ActionRangeError',
15
+ 'ArgumentError',
16
+ 'ChoiceError',
17
+ 'ClosedError',
18
+ 'ConfigurationError',
19
+ 'DeviceError',
20
+ 'EnvironmentIndexError',
21
+ 'Error',
22
+ 'LibraryError',
23
+ 'MissingFileError',
24
+ 'SignatureError',
25
+ 'StateError',
26
+ 'TrackerError',
27
+ 'UndefinedPathError',
28
+ ]
29
+
30
+
31
+ class Error(Exception):
32
+ """The base of every exception that cuju raises for a failure of its own."""
33
+
34
+ # `KeyError` quotes its message, so every class here prints the message as it is.
35
+ __str__ = Exception.__str__
36
+
37
+
38
+ class ConfigurationError(Error, ValueError):
39
+ """An option of a batch or of a scenario that cuju refuses."""
40
+
41
+
42
+ class ChoiceError(ConfigurationError, KeyError):
43
+ """A name outside the valid ones, such as a representation, an action set or a device."""
44
+
45
+
46
+ class ArgumentError(Error, ValueError):
47
+ """An argument of a call that cuju refuses, such as actions of the wrong shape."""
48
+
49
+
50
+ class ActionRangeError(Error, IndexError):
51
+ """An action index outside the action set, which GRF refuses as well."""
52
+
53
+
54
+ class EnvironmentIndexError(Error, IndexError, RuntimeError):
55
+ """An environment index outside the batch."""
56
+
57
+
58
+ class StateError(Error, ValueError, RuntimeError):
59
+ """A state that does not load into an environment, or a batch that has no GRF state."""
60
+
61
+
62
+ class ClosedError(Error, RuntimeError):
63
+ """A call on a batch after `close`."""
64
+
65
+
66
+ class DeviceError(Error, RuntimeError):
67
+ """A device that cannot run the batch, or a failure of CUDA.
68
+
69
+ Such a device is a missing CUDA GPU, a GPU index past the last, or a processor without AVX2,
70
+ BMI2 or FMA.
71
+ """
72
+
73
+
74
+ class SignatureError(Error, TypeError):
75
+ """Arguments that a function of `cuju.gfootball_engine` does not take.
76
+
77
+ Its message is the one of GRF's `Boost.Python.ArgumentError`, which is a `TypeError` as well.
78
+ """
79
+
80
+
81
+ class TrackerError(Error, RuntimeError):
82
+ """Two engines that GRF's tracker plays in lockstep and whose states differ.
83
+
84
+ GRF ends the process there, and cuju raises this in both threads.
85
+ """
86
+
87
+
88
+ class UndefinedPathError(Error, RuntimeError):
89
+ """An environment that reached a path that GRF leaves undefined."""
90
+
91
+
92
+ class LibraryError(Error, RuntimeError):
93
+ """A failure that the library reports, or a library of another backend."""
94
+
95
+
96
+ class MissingFileError(Error, FileNotFoundError):
97
+ """A scenario file, a bundle, a library or another file that does not exist."""
98
+
99
+
100
+ def _from_library(message: str) -> Error:
101
+ """Returns the exception for a failure message of the library."""
102
+ if 'reached a path that GRF leaves undefined' in message:
103
+ return UndefinedPathError(message)
104
+ # A failed CUDA call starts the message with its name, such as `cudaMalloc`, and a GPU without
105
+ # a kernel is a device fault.
106
+ if message.startswith('cuda') or 'CUDA kernel' in message:
107
+ return DeviceError(message)
108
+ return LibraryError(message)
@@ -0,0 +1,86 @@
1
+ b264e4815699808ea781a31e3430e67fec4fe35fc285594c11b7810c49772ae4 __init__.py
2
+ 88d72e02af9c7b2ea08bffa99ee72facc3f1f557b7cdcb15dc5193a49bc5b861 dump_to_txt.py
3
+ 27704ae6b4d2ac0698d5eeb4815cdf453be71673d83eaaa75d120b1bfac525c7 dump_to_video.py
4
+ 7c41acea5ec089eaacefc52f921d6b503f29457693f9c3e9f3209abb65e0b489 env/__init__.py
5
+ 4d8e168ae3c9fdfc80d6b8ee0e1e67639cebe4fea6e1e360e9467d4d05925f9f env/config.py
6
+ 1c490d448cb0608d02b4c73a21d8065fb0f1990b2c4ed4fac0f689f5137d635a env/constants.py
7
+ 3c80949e1ff15d480e8f54448fa89b5a604279d987879d85d5cbf7a126f27935 env/controller_base.py
8
+ 5bc69d080a30925840168ba117e1540f644d44de42b17aa17baeac8735f2b664 env/event_queue.py
9
+ e430f1853c5d7afbe8b3431c1a56e9354ce58d17805eda1ef725ef08a6e85704 env/football_action_set.py
10
+ 3e4d8fee1793e0565ea02f8a5e1f57fbfcb8ba769eab266c2b90f51a64d6c6cd env/football_action_set_test.py
11
+ 9c810133ad7b546a45e3d7abfcc7d36edeb6dcc14d1960df7162322c23e3a3bd env/football_env.py
12
+ 101504c6f9a5e5440d440b2a4576e690733e0d2cf1a1212f22b8b7cd8fcb21a6 env/football_env_core.py
13
+ 3db3c8a5a72214f699746cc6f9c1b973c01a628636c6206039b0634ed2583f06 env/football_env_test.py
14
+ 12f8348538e9a9eb46a5b18d1c8cfe647a88031cc311d3384fe7a28fe0e6c5cb env/gym_test.py
15
+ bd10f1ae0c174d6f5f8d7e92b5c674bc5dc6c7b4521c31a98f9975136e3adce7 env/observation_preprocessing.py
16
+ a6df0285f27381c95e7b7d441f24e756fb9cc41b6b999f40d3013030b8c709dd env/observation_processor.py
17
+ 3b25b0a259d3e5cd6ed706654a850a58b48cdaca090e6deb6a54c78590d52cc6 env/observation_rotation.py
18
+ ea7a81a77f740a65f660be36ca0e7368ec65b74302f9a09d52175b921c460186 env/observation_rotation_test.py
19
+ 8e36352fe44f461340ae2d331f4f1c1d6a14ae42a8bbdaf7b0372394c48a815d env/player_base.py
20
+ f9342261e79aa8fa1f406556965fc971d5bcdc1aec0043f7e84572cb8ce66244 env/players/__init__.py
21
+ ab59c11b8db096cf3f0dc73e3e69e011ef47a786a7a13aa0685ba4a4d4b129fd env/players/agent.py
22
+ 270d68de8aeac096dec2a13049feb8c1b4a4d42181f179db6ad6cdf19734114d env/players/bot.py
23
+ 61bc5d13ef042cf4803cb718878d0c3779c8103fb6f00e16812202d553fe01d3 env/players/gamepad.py
24
+ a2eacf7cac36cc17f9cd4b5637e1dec703d0e6df8b62ad1660e2ff0c61bc6e30 env/players/keyboard.py
25
+ 3f2f6596a208f62694337a6a9f28238d3a638fff0923d012aed575bbdc101cdc env/players/lazy.py
26
+ 72db29d8163916682066ace5dc0e4e4f6f8a77bd424d87f57b10b0752d2be2eb env/players/ppo2_cnn.py
27
+ 4eeec2c197ca714ab79608613c5ad79ba6a8b54472e680b6796f9c4d74909c49 env/players/replay.py
28
+ 0153880c47062ccddc68508411eb78b3262d6903337f3bfe7487b7d0369c608f env/remote_football_env.py
29
+ a9eb7e158c29252c8e5979cb0dc49cd9c1b36e8076c3bcfa8b73c063314839b5 env/scenario_builder.py
30
+ bdbd39cc56d748c0430cf1da5a121c0b717aa9d716be5b3e00515f2ee069a3b8 env/script_helpers.py
31
+ a0dc12869801bda8f6476b01001bba81b357d21709a34dbdd59fb00cffe03f2e env/script_helpers_test.py
32
+ d0ce2f4d33e670158f58fd9d507a197e700c89add751310746f649a69f45e10a env/wrappers.py
33
+ 228e857392e94f8611b134a6bd98305a2e9b2a5ba370665af2fb1cf8b33029f9 env/wrappers_test.py
34
+ 921e7ec19ee945bf25a8e4e12592fe0f69b2a75d6642d0853c07f569cac33280 eval_server/__init__.py
35
+ fa147a57158d31d5185480a0219aba284bac7691aa95a553329c4d3be8139c3e eval_server/config.py
36
+ 71bb9f2965eb157775cddffd19022bf23fbde86ee21cd9b6dd79a29970e560e2 eval_server/example_client.py
37
+ c8888d53cd712ac84568c9a0b38d86b7e4ddae28c8897851f30d3bc334567f96 eval_server/proto/game_server.proto
38
+ bce3cdbfdfdd3d98d29421b1b7877cb25bc61d9aed89867e81a22b8cb2af0841 eval_server/proto/game_server_pb2.py
39
+ 4fa5a6d07d4f9a31d5f7518eeedb9a937f8939b130f7f97666fbdeaba8e6366a eval_server/proto/game_server_pb2_grpc.py
40
+ a0983b8cdbc74a28919d5fce0d0bdcd97c7415b0b653a1c6cf78109f02926ce2 eval_server/proto/master.proto
41
+ fe402c9d98d3d8f0629043a0b23847e7ef1c445b32addc427c0215263443c314 eval_server/proto/master_pb2.py
42
+ 498a28c1fc01c05679c0c484a984183d16d2eba6bb197dd7f618289f3c4ecb96 eval_server/proto/master_pb2_grpc.py
43
+ 6cf3a00271ad4c38d04ade10ccdcc4549a835c544caf0a91fe6dc5d22daa7cbc eval_server/utils.py
44
+ f9342261e79aa8fa1f406556965fc971d5bcdc1aec0043f7e84572cb8ce66244 examples/__init__.py
45
+ 92268b41b3d09d30015d7c874e87489054798566187b9278baf964d6c9b4ada0 examples/models.py
46
+ d97f82967f0de462846f6c965900b4704a26664dd18ef20b35eaf001ca1ff064 examples/run_multiagent_rllib.py
47
+ 89d33ffda3c719f69d65e8912428ec59e26a7b96a137f4e9e7c959e60914f6ef examples/run_ppo2.py
48
+ f3a0f999924a0f5a3f400f6194e6c0301ae84a9c16427b58a26bfe3612160e1e play_game.py
49
+ 926e81758bb02f01308f5e3303ce089c2c73151bd4f6232fb2d538b7e7647dea replay.py
50
+ 975ec04d474463d6a956182a02777ac482230623e70a48bf68afa90f11ac7cda scenarios/11_vs_11_competition.py
51
+ ee53e4f4eeacaede071d8f403db9e8042d78c6e8b20b4813ee12dd25d67b37c8 scenarios/11_vs_11_easy_stochastic.py
52
+ 7893abc1af53cde29332c0b6d4b19476bbc44a7eb939f1e19543cf26e4b91ae3 scenarios/11_vs_11_hard_stochastic.py
53
+ 6224d15e7c33e70c2769086eb39abdb301580827bee759367f324e25811f4b60 scenarios/11_vs_11_kaggle.py
54
+ e643984eb240dc7d657c41ee03cee5fa9265e309f07a4c8eae7bc81a03c3daa0 scenarios/11_vs_11_stochastic.py
55
+ 27dea46e204f0007587e2cdd4f3b9815500d24b89b20f6984901ed6f41b5da06 scenarios/1_vs_1_easy.py
56
+ 0da7d4f652847308e038bd676e81c89ca16978357fedee05b36b0b9dcbeefdc4 scenarios/5_vs_5.py
57
+ 20d1ee5f07353e0879f79544ff5b518d3ade45feb84ed4fb4a51b3f3fa06a8bc scenarios/__init__.py
58
+ b3fc1a0edf4d941c8c2a09d56b739d37351ab6b1c04bc97df574dd28a87e3234 scenarios/academy_3_vs_1_with_keeper.py
59
+ 4ee756f2d8f3520ad9a743302be9c99611f6302d8379136c335057c4968ee596 scenarios/academy_corner.py
60
+ a120f71e766a747fe89087012683db8eca3386187d5b89396fdc0e27e8b5e0f4 scenarios/academy_counterattack_easy.py
61
+ 835d00f1eec39e0f9a6b11a80f982f402af11c04cffab6d0bb3c139f8fba4d53 scenarios/academy_counterattack_hard.py
62
+ 9364da7e525ee32ee8aa8cbf735bd0937a165f33643f1062780a14e57bf56395 scenarios/academy_empty_goal.py
63
+ dcd3d347224d9d4524c397e508e9d3a06e2b5e4c8f352c18beb45860fc804cd4 scenarios/academy_empty_goal_close.py
64
+ 90817a6eaa0e25abfbcc292e1efc6527762eafdbb00be66c21586c4d13e10931 scenarios/academy_pass_and_shoot_with_keeper.py
65
+ 01289565e4789c888e3f130cf3c0afde44056a5e5e40cfb24e8e3c2805be3d81 scenarios/academy_run_pass_and_shoot_with_keeper.py
66
+ ad7c7152b664b26a39038eb542e61b9005be3f513d80a29112259991661acf56 scenarios/academy_run_to_score.py
67
+ 71f4e87afb02d19e00718273a59744f319f7fb873863e2ff880b2d6400fda800 scenarios/academy_run_to_score_with_keeper.py
68
+ d01099fbafbe14aa951547a664a0e5b83b933480d9aa606d8be2ca5221bda504 scenarios/academy_single_goal_versus_lazy.py
69
+ cffb876d6585692cfb5e570392bc2d4801db54ac5fba9d44f4a38745d27b308f scenarios/test_example_multiagent.py
70
+ a73469cb4004119084fee29fea11802029f2b1ba0d8eaa59210f4949d7bcf8da scenarios/tests/11_vs_11_deterministic.py
71
+ bbe2f69b87f8180f29c3253252773f4f691992822e44dc5ad7bba6a4b085468b scenarios/tests/11_vs_11_easy_deterministic.py
72
+ 26a9c90d64f79f288555d91da6519f580d4b32c2cf033c5d2872e349925fa787 scenarios/tests/11_vs_11_hard_deterministic.py
73
+ 947a318532b95e730588ccac72baeb9a2640201bda0e15cb954c9629d513928a scenarios/tests/11_vs_11_single_goal_deterministic.py
74
+ 40d5195c35906c5528912325a0c6b31414510bf7db117d2b5075c2ffe7db9d53 scenarios/tests/11_vs_11_single_goal_stochastic.py
75
+ 3eb683ee01fc3b07f6eacf2a3225100c950797765aa80b25eea26c5bda4daea0 scenarios/tests/11_vs_4_offence_deterministic.py
76
+ 40a61d3480317262f3d42fdb6577fec3ee63e9b3605a0366aa19b3fb8a64bd32 scenarios/tests/11_vs_4_offence_stochastic.py
77
+ 20d1ee5f07353e0879f79544ff5b518d3ade45feb84ed4fb4a51b3f3fa06a8bc scenarios/tests/__init__.py
78
+ 92173ba453ade4d44ea54f029701121e3bf057819fdb56264739f8a27378a71b scenarios/tests/corner_test.py
79
+ 12dc426d03ad0e6a7065ba35125d32daea5aaba5a5b8eaa7463175d304927b18 scenarios/tests/goal_test.py
80
+ b4fa97e53af88b7d840b50c1664077cba8daf2f96ff6cd55563ef2d67dd64c56 scenarios/tests/keeper_test.py
81
+ b59cb07c4bf327a80447455cfa6134a6a5dc2ab5e60da887518174a00d2d1709 scenarios/tests/kickoff_for_goal_loosing_team_test.py
82
+ d49e71258e3469d9fd7a4d8942a66127d8c9ec9f34d9167292e04d1547813ede scenarios/tests/multiagent_wrapper.py
83
+ e4b26afe8bfc49105c54a4279faf12ab62bd06abf6b79c796f065b68532bee18 scenarios/tests/offside_test.py
84
+ cd0ff408f99152c5e1e4372d3dc6fa418223ed669e52008f37b77f4270902823 scenarios/tests/penalty.py
85
+ 7ce6608417fa62ed12cf83fa7a001a3a04bf41cb8d81f6976391756bddc52669 scenarios/tests/second_half.py
86
+ 08544bf0c35b243a8effdabfe2bea2302bed2972d6a5937e302102777c7d64d2 scenarios/tests/symmetric.py
@@ -0,0 +1,60 @@
1
+ # coding=utf-8
2
+ # Copyright 2019 Google LLC
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # Modified by the cuju Authors in 2026, in the import lines that ci/port_gfootball.py lists.
15
+ # SPDX-License-Identifier: Apache-2.0
16
+
17
+ """Google Research Football."""
18
+
19
+ from cuju.gfootball.env import scenario_builder
20
+
21
+ from cuju.gfootball import _gym as gym
22
+ from cuju.gfootball._gym import register
23
+
24
+
25
+ for env_name in scenario_builder.all_scenarios():
26
+ register(
27
+ id='GFootball-{env_name}-SMM-v0'.format(env_name=env_name),
28
+ entry_point='cuju.gfootball.env:create_environment',
29
+ kwargs={
30
+ 'env_name': env_name,
31
+ 'representation': 'extracted'
32
+ },
33
+ )
34
+
35
+ register(
36
+ id='GFootball-{env_name}-Pixels-v0'.format(env_name=env_name),
37
+ entry_point='cuju.gfootball.env:create_environment',
38
+ kwargs={
39
+ 'env_name': env_name,
40
+ 'representation': 'pixels'
41
+ },
42
+ )
43
+
44
+ register(
45
+ id='GFootball-{env_name}-simple115-v0'.format(env_name=env_name),
46
+ entry_point='cuju.gfootball.env:create_environment',
47
+ kwargs={
48
+ 'env_name': env_name,
49
+ 'representation': 'simple115'
50
+ },
51
+ )
52
+
53
+ register(
54
+ id='GFootball-{env_name}-simple115v2-v0'.format(env_name=env_name),
55
+ entry_point='cuju.gfootball.env:create_environment',
56
+ kwargs={
57
+ 'env_name': env_name,
58
+ 'representation': 'simple115v2'
59
+ },
60
+ )
cuju/gfootball/_cv2.py ADDED
@@ -0,0 +1,43 @@
1
+ # Copyright 2026 The cuju Authors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """OpenCV for GRF's Python, imported at the first use of one of its names.
4
+
5
+ GRF imports `cv2` at the top of `football_env_core.py`, `observation_processor.py`, `wrappers.py`
6
+ and `remote_football_env.py`, and uses it for frames, videos, pixel observations and `imshow`
7
+ alone. The port imports this module as `cv2` in its place, so `cuju.gfootball.env` imports without
8
+ OpenCV. The first name read from it imports the real `cv2` and serves that module's attribute.
9
+ Where OpenCV is missing, that read raises `ModuleNotFoundError: No module named 'cv2'`, the error of
10
+ GRF's own import, moved from the import to the first use.
11
+ """
12
+
13
+ import importlib
14
+ from types import ModuleType
15
+
16
+ _module: ModuleType | None = None
17
+
18
+
19
+ def _cv2() -> ModuleType:
20
+ """Returns the real `cv2`, imported once."""
21
+ global _module
22
+ if _module is None:
23
+ _module = importlib.import_module('cv2')
24
+ return _module
25
+
26
+
27
+ def __getattr__(name: str):
28
+ if name.startswith('__') and name.endswith('__'):
29
+ # Probes such as `hasattr(module, '__path__')` expect an `AttributeError` for a name that
30
+ # is missing, so a special name gets one where OpenCV is missing.
31
+ try:
32
+ module = _cv2()
33
+ except ImportError:
34
+ raise AttributeError(f'module {__name__!r} has no attribute {name!r}') from None
35
+ return getattr(module, name)
36
+ return getattr(_cv2(), name)
37
+
38
+
39
+ def __dir__() -> list[str]:
40
+ try:
41
+ return sorted(set(globals()) | set(dir(_cv2())))
42
+ except ImportError:
43
+ return sorted(globals())
@@ -0,0 +1,88 @@
1
+ # Copyright 2026 The cuju Authors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """gym for GRF's Python, the installed gym wherever GRF runs on it, else gym 0.21's own core.
4
+
5
+ GRF requires `gym<=0.21.0`, and it runs on every gym up to 0.24, which `import gfootball` imports
6
+ and registers its ids with. Gym 0.25 runs it with numpy 1, and with numpy 2 its step checker reads
7
+ `np.bool8`, which numpy 2 removed, so every step fails. Gym 0.26 took gymnasium's interface, and
8
+ GRF's `reset` fails there. The port imports this module as `gym`, and it chooses once, at its
9
+ import. An installed gym on which GRF runs, and that imports, serves as itself, so the port's
10
+ environments are instances of its `gym.Env`, its `gym.make` finds GRF's ids, and its warnings are
11
+ GRF's. On every other gym the module serves the core of gym 0.21.0 vendored in `_vendored`, under
12
+ gym's MIT license, whose registry belongs to the port alone. `VENDORED` tells which of the two
13
+ serves.
14
+ """
15
+
16
+ import importlib
17
+ import importlib.metadata
18
+ import re
19
+ from types import ModuleType
20
+
21
+
22
+ def _version(name: str) -> tuple[int, int] | None:
23
+ """Returns the major and minor version of an installed distribution, or `None`."""
24
+ try:
25
+ version = importlib.metadata.version(name)
26
+ except importlib.metadata.PackageNotFoundError:
27
+ return None
28
+ match = re.match(r'(\d+)\.(\d+)', version)
29
+ return (int(match[1]), int(match[2])) if match else None
30
+
31
+
32
+ def _grf_runs_on(gym: tuple[int, int], numpy: tuple[int, int] | None) -> bool:
33
+ """Returns whether GRF's Python runs on a gym of version `gym` with a numpy of `numpy`."""
34
+ if gym <= (0, 24):
35
+ return True
36
+ return gym[:2] == (0, 25) and numpy is not None and numpy < (2, 0)
37
+
38
+
39
+ def _installed_gym() -> ModuleType | None:
40
+ """Returns the installed gym where GRF runs on it and it imports, else `None`."""
41
+ gym = _version('gym')
42
+ if gym is None or not _grf_runs_on(gym, _version('numpy')):
43
+ return None
44
+ # A gym that fails to import, with any error, leaves the choice to the vendored core.
45
+ try:
46
+ return importlib.import_module('gym')
47
+ except Exception:
48
+ return None
49
+
50
+
51
+ _source = _installed_gym()
52
+ VENDORED = _source is None
53
+ if _source is None:
54
+ from . import _vendored as _source
55
+
56
+ Env = _source.Env
57
+ Wrapper = _source.Wrapper
58
+ ObservationWrapper = _source.ObservationWrapper
59
+ ActionWrapper = _source.ActionWrapper
60
+ RewardWrapper = _source.RewardWrapper
61
+ Space = _source.Space
62
+ spaces = _source.spaces
63
+ envs = _source.envs
64
+ wrappers = _source.wrappers
65
+ make = _source.make
66
+ spec = _source.spec
67
+ register = _source.register
68
+ logger = _source.logger
69
+ error = _source.error
70
+ __version__ = _source.__version__
71
+
72
+ __all__ = [
73
+ 'VENDORED',
74
+ 'ActionWrapper',
75
+ 'Env',
76
+ 'ObservationWrapper',
77
+ 'RewardWrapper',
78
+ 'Space',
79
+ 'Wrapper',
80
+ 'envs',
81
+ 'error',
82
+ 'logger',
83
+ 'make',
84
+ 'register',
85
+ 'spaces',
86
+ 'spec',
87
+ 'wrappers',
88
+ ]
@@ -0,0 +1,22 @@
1
+ 1e510596d863327524ddb73960f5935f5996e41bf4a035f0d64e6b7504c0c428 core.py
2
+ c3237c67c4ac018b53f330e01f9300b2c078dc665a90799599959d6723caaf1a envs/registration.py
3
+ c78ea8e2d71c95fcda7336970bc125252a3731c9889982b662d6aa2180427664 error.py
4
+ 4e7d57fdf66dd9b657c8466ccd54b1355edd0a139a4aa39f7b76c8c01737ae7d logger.py
5
+ e4756a6ff6ef8831a542ffe1c07e1c7dc20662b70a2f9340c7b3626ce1e76ead spaces/__init__.py
6
+ 53ef15d40097fd14b6b52bc90c7cf8ff74f36fec6d87985157923e54f1014ce6 spaces/box.py
7
+ 5406bef65350b9a64104757cec10b9aabf4deef20c69158ea93ed2e12c46f2f0 spaces/dict.py
8
+ 404acf92626c8b5cb4ecbf8c50144d03fe5caf1cf9c2bff6c2ed555901754ded spaces/discrete.py
9
+ a739f270b218fbd1dfe737c1e7e11fa1e7101ee7ab89c1ab938fefaf898d2a32 spaces/multi_binary.py
10
+ d38c09ee71f782d4e81aeace08f436610e754288e0d586ff6afb5449638d4ee8 spaces/multi_discrete.py
11
+ d185a7a6ea94c105e9199f860c805bfcb2b85af20760e109bae66c010cb34a23 spaces/space.py
12
+ 93b0611426a7e3ea95d0019cb8478666038e76a54178feb8a27c7bbb0032e36c spaces/tuple.py
13
+ 85fc7855a1ba0ab234f2005627efa7319218f85ee6540db93d9f428533f74e5c spaces/utils.py
14
+ 073cfca74550051a19bf85be0f989d73b41953a2651410aca741a0988280cf10 utils/__init__.py
15
+ 10ef86e5efb7e57fbea2f3f1b16554aadf213e0960ef8fc21527e13a7a702b3a utils/closer.py
16
+ b93aec0dab4898f0bdb024b6e9ec2ba8dc81fa1bb8957b79c6c6be683aaf9914 utils/colorize.py
17
+ 9c8b74c6c620cf12b732021d3f829e58d95ba634c0be2c6bba0035241f2e8597 utils/ezpickle.py
18
+ b32689b72c4207723dfd57fc801691e2af830eba233d8884cd92ca3a82f2f6d0 utils/json_utils.py
19
+ 1e471413b35e82b5bef62e56ae55ae571749d68b5094b4eb5b164d457c41366d utils/seeding.py
20
+ 02c36b12062670060e48398a6ba4beeebad4b012f3c2f063f8230efb5500bd80 version.py
21
+ 23132979e276168cbbf7757c939daa18a021d579c999952977aa315b5dc8cc57 wrappers/order_enforcing.py
22
+ b725e477fe0447d88c23804b71c8539d731f11a79ecdaa7b67c543f596845ef6 wrappers/time_limit.py
@@ -0,0 +1,43 @@
1
+ # Copyright 2026 The cuju Authors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """The core of gym 0.21.0 that `cuju.gfootball._gym` serves where no gym of GRF's version is found.
4
+
5
+ It holds the names of gym's own `gym/__init__.py` that GRF's Python reads, from gym's files
6
+ vendored next to it with their imports pointed inside this package. Its registry is its own, so
7
+ an id registered here reaches `make` of this package alone.
8
+ """
9
+
10
+ from cuju.gfootball._gym._vendored.core import (
11
+ ActionWrapper,
12
+ Env,
13
+ GoalEnv,
14
+ ObservationWrapper,
15
+ RewardWrapper,
16
+ Wrapper,
17
+ )
18
+
19
+ # isort: split
20
+ # The wrappers subclass `Wrapper` as they import, so they follow `core`.
21
+ from cuju.gfootball._gym._vendored import envs, error, logger, spaces, version, wrappers
22
+ from cuju.gfootball._gym._vendored.envs import make, register, spec
23
+ from cuju.gfootball._gym._vendored.spaces import Space
24
+
25
+ __version__ = version.VERSION
26
+
27
+ __all__ = [
28
+ 'ActionWrapper',
29
+ 'Env',
30
+ 'GoalEnv',
31
+ 'ObservationWrapper',
32
+ 'RewardWrapper',
33
+ 'Space',
34
+ 'Wrapper',
35
+ 'envs',
36
+ 'error',
37
+ 'logger',
38
+ 'make',
39
+ 'register',
40
+ 'spaces',
41
+ 'spec',
42
+ 'wrappers',
43
+ ]