-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrandomAgent.py
26 lines (23 loc) · 894 Bytes
/
randomAgent.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
from directions import *
from states import *
from agent import *
class RandomAgent(Agent):
def __init__(self, startingPos, startingDir, environ):
super().__init__(startingPos, startingDir, environ)
self.AgentTypeName = "Random Reflex Agent"
def Run(self):
maxSteps = 100
running = True
if self.PrintMovements:
print("agent starting position: x:{} y:{}".format(self.Position[0],self.Position[1]))
print("agent starting direction: x:{} y:{}".format(self.DirFacingVec[0],self.DirFacingVec[1]))
while running:
if self.Environ.CountDirty() <= 0 or maxSteps <= 0:
running = False
self.CleanTile()
r = random.randint(0,7)
for rotations in range(r):
self.Rotate(CW)
self.MoveForward()
maxSteps -= 1
return