-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVerticalStrat.py
31 lines (26 loc) · 976 Bytes
/
VerticalStrat.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
from AntStrategy import AntStrategy
class VerticalStrat(AntStrategy):
'''Move up and down within grid boundaries'''
def __init__(self, max_x, max_y, anthill):
super().__init__(max_x, max_y, anthill)
self.direction = "NORTH"
def receive_info(self, messages):
'''This ant ignores messages passed to it'''
pass
def send_info(self):
'''This ant doesn't send any messages'''
return []
def one_step(self, x, y, vision, food):
'''Return next move, changing direction when a boundary is reached'''
if self.direction == "SOUTH":
if x < self.max_y:
return self.direction
else:
self.direction = "NORTH"
return self.direction
elif self.direction == "NORTH":
if x > 0:
return self.direction
else:
self.direction = "SOUTH"
return self.direction