-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrobot.py
35 lines (24 loc) · 1.13 KB
/
robot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### DO NOT EDIT THIS FILE ###
import arcade
import numpy as np
import settings
# The Robot class
class Robot:
# Initialisation function to create a new robot
def __init__(self):
# The robot's action range.
self.min_action = -0.05
self.max_action = 0.05
# The robot's current position.
self.state = np.array([0.5, 0.5])
# Function that is called once every loop, to allow the robot to take an action and then update its position
def take_action(self, action, environment):
# Make sure that the action is within the minimum and maximum range
action[0] = np.clip(action[0], self.min_action, self.max_action)
action[1] = np.clip(action[1], self.min_action, self.max_action)
# Execute the action and update the robot's position
self.state = environment.dynamics(self.state, action)
# Function to draw the robot
def draw(self):
# Draw a blue circle onto the screen representing the robot
arcade.draw_circle_filled(settings.SCREEN_SIZE * self.state[0], settings.SCREEN_SIZE * self.state[1], settings.ROBOT_SIZE, settings.ROBOT_COLOUR)