Last active
January 7, 2023 14:19
-
-
Save WhatIThinkAbout/2c7033ec3adeceece0bd0dcf9db668a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' 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