Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygo-agent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Biluo Shen
ygo-agent
Commits
c90562de
Commit
c90562de
authored
Jun 03, 2024
by
sbl1996@126.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Env fault tolerant training via timeout
parent
b7e43382
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
188 additions
and
103 deletions
+188
-103
scripts/battle.py
scripts/battle.py
+4
-2
scripts/cleanba.py
scripts/cleanba.py
+3
-0
scripts/eval.py
scripts/eval.py
+11
-11
ygoenv/ygoenv/ygopro/ygopro.h
ygoenv/ygoenv/ygopro/ygopro.h
+170
-90
No files found.
scripts/battle.py
View file @
c90562de
...
...
@@ -311,6 +311,7 @@ if __name__ == "__main__":
for
idx
,
d
in
enumerate
(
dones1
):
if
not
d
or
(
args
.
accurate
and
collected
[
idx
]):
continue
# c1 = collected[idx]
collected
[
idx
]
=
True
win_reason
=
infos1
[
'win_reason'
][
idx
]
pl
=
1
if
main
[
idx
]
else
-
1
...
...
@@ -323,6 +324,7 @@ if __name__ == "__main__":
win_players
.
append
(
win_player
)
win_agent
=
1
if
main_reward
>
0
else
2
win_agents
.
append
(
win_agent
)
# if not c1:
# print(f"{len(episode_lengths)}: {episode_length}, {main_reward}")
episode_lengths
.
append
(
episode_length
)
episode_rewards
.
append
(
main_reward
)
...
...
scripts/cleanba.py
View file @
c90562de
...
...
@@ -49,6 +49,8 @@ class Args:
"""the frequency of saving the model (in terms of `updates`)"""
checkpoint
:
Optional
[
str
]
=
None
"""the path to the model checkpoint to load"""
timeout
:
int
=
600
"""the timeout of the environment step"""
debug
:
bool
=
False
"""whether to run the script in debug mode"""
...
...
@@ -208,6 +210,7 @@ def make_env(args, seed, num_envs, num_threads, mode='self', thread_affinity_off
async_reset
=
False
,
greedy_reward
=
args
.
greedy_reward
if
not
eval
else
True
,
play_mode
=
mode
,
timeout
=
args
.
timeout
,
)
envs
.
num_envs
=
num_envs
return
envs
...
...
scripts/eval.py
View file @
c90562de
...
...
@@ -210,17 +210,17 @@ if __name__ == "__main__":
for
idx
,
d
in
enumerate
(
dones
):
if
not
d
:
continue
for
i
in
range
(
2
):
deck_time
=
infos
[
'step_time'
][
idx
][
i
]
deck_name
=
deck_names
[
infos
[
'deck'
][
idx
][
i
]]
time_count
=
deck_time_count
[
deck_name
]
avg_time
=
deck_times
[
deck_name
]
avg_time
=
avg_time
*
(
time_count
/
(
time_count
+
1
))
+
deck_time
/
(
time_count
+
1
)
deck_times
[
deck_name
]
=
avg_time
deck_time_count
[
deck_name
]
+=
1
if
deck_time_count
[
deck_name
]
%
100
==
0
:
print
(
f
"Deck {deck_name}: {avg_time:.4f}"
)
#
for i in range(2):
#
deck_time = infos['step_time'][idx][i]
#
deck_name = deck_names[infos['deck'][idx][i]]
#
time_count = deck_time_count[deck_name]
#
avg_time = deck_times[deck_name]
#
avg_time = avg_time * (time_count / (time_count + 1)) + deck_time / (time_count + 1)
#
deck_times[deck_name] = avg_time
#
deck_time_count[deck_name] += 1
#
if deck_time_count[deck_name] % 100 == 0:
#
print(f"Deck {deck_name}: {avg_time:.4f}")
win_reason
=
infos
[
'win_reason'
][
idx
]
episode_length
=
infos
[
'l'
][
idx
]
...
...
ygoenv/ygoenv/ygopro/ygopro.h
View file @
c90562de
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment