-
Notifications
You must be signed in to change notification settings - Fork 1
/
robot.py
41 lines (34 loc) · 1.68 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
36
37
38
39
40
41
import numpy as np
class Robot(object):
def __init__(self, maze_dim):
'''
Use the initialization function to set up attributes that your robot
will use to learn and navigate the maze. Some initial attributes are
provided based on common information, including the size of the maze
the robot is placed in.
'''
self.location = [0, 0]
self.heading = 'up'
self.maze_dim = maze_dim
def next_move(self, sensors):
'''
Use this function to determine the next move the robot should make,
based on the input from the sensors after its previous move. Sensor
inputs are a list of three distances from the robot's left, front, and
right-facing sensors, in that order.
Outputs should be a tuple of two values. The first value indicates
robot rotation (if any), as a number: 0 for no rotation, +90 for a
90-degree rotation clockwise, and -90 for a 90-degree rotation
counterclockwise. Other values will result in no rotation. The second
value indicates robot movement, and the robot will attempt to move the
number of indicated squares: a positive number indicates forwards
movement, while a negative number indicates backwards movement. The
robot may move a maximum of three units per turn. Any excess movement
is ignored.
If the robot wants to end a run (e.g. during the first training run in
the maze) then returing the tuple ('Reset', 'Reset') will indicate to
the tester to end the run and return the robot to the start.
'''
rotation = 0
movement = 0
return rotation, movement