Skip to content
Snippets Groups Projects
Commit 1f1738ab authored by phwitte's avatar phwitte
Browse files

update nearest_neighbour, parameters

parent d905e2bf
Branches
Tags
No related merge requests found
...@@ -40,10 +40,10 @@ Am = 5 * (rr**2) * t ...@@ -40,10 +40,10 @@ Am = 5 * (rr**2) * t
#mutate values #mutate values
m_zoo_r = 5 m_zoo_r = 5
m_zoa_r = 10 m_zoa_r = 10
m_speed = 0.5 m_speed = 0.1
m_food = 0.1 m_food = 0.1
m_pred = 0.1 m_pred = 0.1
m_noise = 0.1 m_noise = 0.05
#-----Agent class-------------------- #-----Agent class--------------------
...@@ -160,7 +160,8 @@ class Predator: ...@@ -160,7 +160,8 @@ class Predator:
view_angle = 360-(self.blind_angle*2) view_angle = 360-(self.blind_angle*2)
self.zoa_r = 20*math.sqrt(As/view_angle) self.zoa_r = 20*math.sqrt(As/view_angle)
#self.blind_angle = (360 - math.degrees(As/(self.zoa_r**2)) ) / 2 #self.blind_angle = (360 - math.degrees(As/(self.zoa_r**2)) ) / 2
self.turn_angle = math.degrees(1.1*Am/(2*(self.speed**2))) #self.turn_angle = math.degrees(1.5*Am/(2*(self.speed**2)))
self.turn_angle = 140
return(self) return(self)
...@@ -219,22 +220,30 @@ def calc_angle(x1, y1, x2, y2): ...@@ -219,22 +220,30 @@ def calc_angle(x1, y1, x2, y2):
# returns nearest neighbour of a in aas # returns nearest neighbour of a in aas
def nearest_neighbour(a,aas): def nearest_neighbour(a,aas):
minDis = float('inf') minDis = float('inf')
nn = None nn = None
for b in aas: for b in aas:
disVecX = b.point.getX() - a.point.getX()
disVecY = b.point.getY() - a.point.getY()
alpha = calc_angle(a.Velocity_x,a.Velocity_y, disVecX, disVecY)
if (a == b): if (a == b):
True True
elif alpha < 180 - a.blind_angle and alpha > 180 + a.blind_angle:
True
elif (nn == None): elif (nn == None):
nn = b nn = b
else: else:
dis = distance(a.point.getX(),b.point.getX(), a.point.getY(), b.point.getY()) dis = distance(a.point.getX(),b.point.getX(), a.point.getY(), b.point.getY())
if(dis < minDis): if(dis < minDis):
minDis = dis minDis = dis
nn = b nn = b
return nn return nn
#-----couzin movement-------------------- #-----couzin movement--------------------
# returns three lists, one for each zone, # returns three lists, one for each zone,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment