Skip to content
Snippets Groups Projects
Commit 6196e532 authored by Tessaris Sergio's avatar Tessaris Sergio
Browse files

api: extend reporting Player's end_episode method

parent a5ce25f8
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment