As a toy, it works well but obviously, when It scales up it bogs down. How can I do this system without asking turtles to ask the other turtles? the code is thus.
to go
ask turtles
[
ask other turtles [
set heading towards myself
let D distance myself
let C .1 / D - 1 / (D ^ 2)
if C > 1 [set C 1]
fd C
]
]
tick
end
I should know how to do this but the brain is not working. I will race y'all to the answer and post my own if I get it first.
Were you thinking of this?
turtles-own [m]
to setup
ca
crt 1000 [
setxy random-xcor random-ycor
set shape "dot"
set color white
set m random-float 5
set size 2 * (m / pi) ^ .5
]
end
to go
ask turtles
[
set heading weighted-mean-heading other turtles
let mv sum [m / (distance myself ^ 2) / [m] of myself ] of other turtles
if mv > .1 [set mv 1]
if mv < -.1 [ set mv -1]
bk mv
]
ask turtles
[
ask other turtles in-radius (size / 4) [ask myself [set m m + [m] of myself] die ]
set size 2 * (m / pi) ^ .5
]
end
to-report weighted-mean-heading [turts]
let mean-x sum [sin towards myself * m / (distance myself ^ 2)] of turts / sum [m / distance myself ^ 2] of turts / m
let mean-y sum [cos towards myself * m / (distance myself ^ 2)] of turts / sum [m / distance myself ^ 2] of turts / m
report atan mean-x mean-y
end