Skip to content

Instantly share code, notes, and snippets.

@WhatIThinkAbout
Last active January 7, 2023 14:19
Show Gist options
  • Select an option

  • Save WhatIThinkAbout/2c7033ec3adeceece0bd0dcf9db668a8 to your computer and use it in GitHub Desktop.

Select an option

Save WhatIThinkAbout/2c7033ec3adeceece0bd0dcf9db668a8 to your computer and use it in GitHub Desktop.
''' the first graphical environment '''
class BabyRobotEnv_v3( BabyRobotEnv_v2 ):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# graphical creation of the level
self.level = GridLevel( **kwargs )
# add baby robot
self.robot = RobotDraw(self.level,**kwargs)
self.robot.draw()
def reset(self, seed=None, return_info=False, options=None):
super().reset(seed=seed)
# reset Baby Robot's position in the grid
self.robot.set_cell_position(self.initial_pos)
self.robot.reset()
self.x = self.initial_pos[0]
self.y = self.initial_pos[1]
info = {}
return np.array([self.x,self.y]),info
def render(self, action=0, reward=0 ):
''' render as an HTML5 canvas '''
print(f"{Actions(action): <5}: ({self.x},{self.y}) reward = {reward}")
# move baby robot to the current position
self.robot.move(self.x,self.y)
return self.level.draw()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment