Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DataScienceSWP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
phwitte
DataScienceSWP
Commits
1f1738ab
Commit
1f1738ab
authored
7 years ago
by
phwitte
Browse files
Options
Downloads
Patches
Plain Diff
update nearest_neighbour, parameters
parent
d905e2bf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ackland_schoen.py
+13
-4
13 additions, 4 deletions
ackland_schoen.py
with
13 additions
and
4 deletions
ackland_schoen.py
+
13
−
4
View file @
1f1738ab
...
@@ -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,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment