Skip to content

Commit 233e420

Browse files
authored
Merge pull request #18 from huangshiyu13/main
update
2 parents a0d057d + e70cae9 commit 233e420

12 files changed

Lines changed: 354 additions & 144 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test:
1212
lint:
1313
$(call check_install, ruff)
1414
ruff ${PYTHON_FILES} --select=E9,F63,F7,F82 --show-source
15-
ruff ${PYTHON_FILES} --exit-zero
15+
ruff ${PYTHON_FILES} --exit-zero | grep -v '501\|405\|401\|402\|403\|722'
1616

1717
format:
1818
$(call check_install, isort)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ For example, you can evaluate tizero with random agent as below:
4444
tizero eval --left_agent submission/tizero --right_agent submission/random_agent --total_game 10
4545
```
4646

47+
For evaluations for JiDi submissions on other games, please refer to the [Arena](https://openrl-docs.readthedocs.io/en/latest/arena/index.html) of OpenRL
48+
and this [example](https://github.com/OpenRL-Lab/openrl/tree/main/examples/snake) for the snake game.
4749

4850
### Show a saved dump file
4951

docs/index.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,47 @@ Installation
1212
____________
1313

1414
* Follow the instructions in `gfootball <https://github.com/google-research/football#on-your-computer>`_ to set up the environment.
15-
* ``pip install gfootball``
15+
* ``pip install gfootball openrl "openrl[selfplay]"``
1616
* ``pip install tizero`` (or clone this repo and ``pip install -e .`` ).
1717
* test the installation by ``python3 -m gfootball.play_game --action_set=full`` .
1818

1919

20+
Evaluate JiDi submissions locally
21+
____________
22+
23+
You can evaluate your agent locally using tizero:
24+
25+
.. code-block:: bash
26+
27+
tizero eval --left_agent submission_dir1 --right_agent submission_dir2 --total_game 10
28+
29+
30+
For example, you can evaluate tizero with random agent as below:
31+
32+
.. code-block:: bash
33+
34+
tizero eval --left_agent submission/tizero --right_agent submission/random_agent --total_game 10
35+
36+
37+
For evaluations for JiDi submissions on other games, please refer to the `Arena <https://openrl-docs.readthedocs.io/en/latest/arena/index.html>`_ of OpenRL
38+
and this `example <https://github.com/OpenRL-Lab/openrl/tree/main/examples/snake>`_ for the snake game.
39+
40+
Show a saved dump file
41+
____________
42+
43+
* show detailed infomation of a match via: ``tizero show dump_file``
44+
* show keypoints of a mactch via: ``tizero keypoint dump_file``
45+
46+
You can download an example dump file from `here <http://jidiai.cn/daily_6484285/daily_6484285.dump>`_.
47+
48+
Then execute: ``tizero show daily_6484285.dump`` or ``tizero keypoint daily_6484285.dump`` . Then you will see a GUI as below:
49+
50+
.. image::
51+
_static/images/show_dump.png
52+
:width: 1000
53+
:align: center
54+
55+
2056
Convert dump file to video
2157
____________
2258

tests/test_env.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def raw_env():
55
from tizero.football_env.football_jidi_eval import FootballJiDiEnv
66

77
env = FootballJiDiEnv("11_vs_11_jidi_eval")
8-
reset_obs = env.reset()
8+
env.reset()
99

1010
single_action = np.zeros(20)
1111
single_action[-1] = 1

tizero/football_env/football_jidi_eval.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def reset(self):
8989

9090
def add_control_index(self, raw_obs):
9191
for i, o in enumerate(raw_obs):
92-
if not "controlled_player_index" in o:
92+
if "controlled_player_index" not in o:
9393
o["controlled_player_index"] = i % 11
9494
return raw_obs
9595

tizero/football_env/football_pettingzoo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class FootballAECEnv(AECEnv):
3333
@property
3434
def agent_num(self):
3535
return self.player_each_side
36+
3637
def __init__(self, render_mode: Optional[str] = None, id: str = None):
3738
self.env = FootballJiDiEnv(scenario_name=id.split("/")[-1])
3839

tizero/football_env/scenarios/football_scenario.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def test_scenario():
140140
for i in range(200):
141141
obs = raw_o[0]
142142
active_position = obs["left_team"][obs["active"]]
143-
sticky_actions = obs["sticky_actions"][:10]
144-
active_direction = obs["left_team_direction"][obs["active"]]
143+
# sticky_actions = obs["sticky_actions"][:10]
144+
# active_direction = obs["left_team_direction"][obs["active"]]
145145
relative_ball_position = obs["ball"][:2] - active_position
146146
all_directions_vecs = [
147147
np.array(v) / np.linalg.norm(np.array(v)) for v in ALL_DIRECTION_VECS

tizero/utils/script_helpers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ def load_dump(self, dump_file):
8282
return dump
8383
dump.append(step)
8484

85-
def dump_to_txt(self, dump_file, output, include_debug):
86-
with open(output, "w") as out_fd:
87-
dump = self.load_dump(dump_file)
88-
if not include_debug:
89-
for s in dump:
90-
if "debug" in s:
91-
del s["debug"]
92-
with open(output, "w") as f:
93-
f.write(str(dump))
85+
# def dump_to_txt(self, dump_file, output, include_debug):
86+
# with open(output, "w") as out_fd:
87+
# dump = self.load_dump(dump_file)
88+
# if not include_debug:
89+
# for s in dump:
90+
# if "debug" in s:
91+
# del s["debug"]
92+
# with open(output, "w") as f:
93+
# f.write(str(dump))
9494

9595
def dump_to_video(self, dump_file, directory=None, episode_length=None):
9696
dump_path = Path(dump_file)
@@ -124,7 +124,7 @@ def dump_to_video(self, dump_file, directory=None, episode_length=None):
124124
processor.update(dump[step])
125125

126126
del processor
127-
processor = None
127+
# processor = None
128128

129129
avi_files = []
130130
try_time = 0

tizero/utils/visualize_tools/game_graph/game_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ def s_step(self):
286286
def e_step(self):
287287
return self.subgames[-1].e_step if len(self) > 0 else None
288288

289-
@property
290-
def n_steps(self):
291-
return self.e_step - self.s_step + 1
289+
# @property
290+
# def n_steps(self):
291+
# return self.e_step - self.s_step + 1
292292

293293
@property
294294
def n_left(self):

tizero/utils/visualize_tools/visualizer/team_info_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ def get_df(self, obs, team, step):
110110

111111
if team == "left":
112112
roles = self.left_team_roles
113-
n = self.n_left
113+
# n = self.n_left
114114
else:
115115
roles = self.right_team_roles
116-
n = self.n_right
116+
# n = self.n_right
117117

118118
roles = [SIMPLE_ROLES(r) + str(idx) for idx, r in enumerate(roles)]
119119

0 commit comments

Comments
 (0)