Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wumpus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tessaris Sergio
wumpus
Commits
6196e532
Commit
6196e532
authored
4 years ago
by
Tessaris Sergio
Browse files
Options
Downloads
Patches
Plain Diff
api: extend reporting Player's end_episode method
parent
a5ce25f8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/eater-usage.py
+2
-2
2 additions, 2 deletions
examples/eater-usage.py
wumpus/gridworld.py
+4
-3
4 additions, 3 deletions
wumpus/gridworld.py
with
6 additions
and
5 deletions
examples/eater-usage.py
+
2
−
2
View file @
6196e532
...
...
@@ -49,9 +49,9 @@ class MyPlayer(InformedPlayer):
self
.
_say
(
'
Available actions: {}
'
.
format
({
a
.
name
:
a
.
value
for
a
in
Eater
.
Actions
}))
def
end_episode
(
self
):
def
end_episode
(
self
,
outcome
:
int
,
alive
:
bool
,
success
:
bool
):
"""
Method called at the when an episode is completed.
"""
self
.
_say
(
'
Episode completed, my reward is {}
'
.
format
(
self
.
reward
))
self
.
_say
(
'
Episode completed, my reward is {}
'
.
format
(
outcome
))
# random player
def
play
(
self
,
turn
:
int
,
percept
:
Eater
.
Percept
,
actions
:
Iterable
[
Eater
.
Actions
])
->
Eater
.
Actions
:
...
...
This diff is collapsed.
Click to expand it.
wumpus/gridworld.py
+
4
−
3
View file @
6196e532
...
...
@@ -435,8 +435,9 @@ class Player(object):
"""
Method called at the beginning of the episode.
"""
pass
def
end_episode
(
self
):
"""
Method called at the when an episode is completed.
"""
def
end_episode
(
self
,
outcome
:
int
,
alive
:
bool
,
success
:
bool
):
"""
Method called at the when an episode is completed with the outcome of the game and whether the agent was still alive and successfull.
"""
pass
def
play
(
self
,
turn
:
int
,
percept
:
Percept
,
actions
:
Iterable
[
Agent
.
Actions
])
->
Agent
.
Actions
:
...
...
@@ -530,7 +531,7 @@ def run_episode(world: GridWorld, agent: Agent, player: Player, horizon: int = 0
else
:
print
(
'
Episode terminated by maximum number of steps ({}).
'
.
format
(
horizon
),
file
=
outf
)
player
.
end_episode
()
player
.
end_episode
(
agent
.
reward
,
agent
.
isAlive
,
agent
.
success
)
print
(
world
,
file
=
outf
)
print
(
'
Episode terminated with a reward of {} for agent {}
'
.
format
(
agent
.
reward
,
agent
.
name
),
file
=
outf
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment