如何在Netlogo中设置来自nest的agentset的标题
我计划做的是让一群代理从世界各地的巢穴蜂拥而至 我使用植绒代码,我有问题,以确定标题的凝聚部分。既然所有的特工都要离开巢穴,我该如何设置他们的方向 编辑代码后出现的错误有:如何在Netlogo中设置来自nest的agentset的标题,netlogo,Netlogo,我计划做的是让一群代理从世界各地的巢穴蜂拥而至 我使用植绒代码,我有问题,以确定标题的凝聚部分。既然所有的特工都要离开巢穴,我该如何设置他们的方向 编辑代码后出现的错误有: No heading is defined from a point (0,0) to that same point. error while turtle 1 running TOWARDS called by procedure AVERAGE-HEADING-TOWARDS-FLOCKMATES called
No heading is defined from a point (0,0) to that same point.
error while turtle 1 running TOWARDS
called by procedure AVERAGE-HEADING-TOWARDS-FLOCKMATES
called by procedure COHERE
called by procedure FLOCK
以下是agentset的代码:
to setup
clear-all
let number-of-groups 3
let turtles-per-group 4
create-turtles turtles-per-group * number-of-groups
[ set color red
set size 1.5
set pen-mode "down"
]
set groups [] ; empty list
repeat number-of-groups [
let new-group n-of turtles-per-group turtles with [
not is-agentset? my-group
]
ask new-group [ set my-group new-group ]
set groups lput new-group groups
]
reset-ticks
end
to go
ask turtles [flock]
end
这是植绒部分
to flock
find-flockmates
if any? flockmates
[
find-nearest-neighbor
ifelse distance nearest-neighbor < minimum-separation
[ separate ]
[ align
cohere ] ]
end
to find-flockmates ;; turtle procedure
set flockmates my-group
end
to find-nearest-neighbor ;; turtle procedure
set nearest-neighbor min-one-of flockmates [distance myself]
end
;;; COHERE
to cohere
turn-towards average-heading-towards-flockmates max-cohere-turn
end
to-report average-heading-towards-flockmates
let x-component mean [sin (towards myself + 180)] of flockmates
let y-component mean [cos (towards myself + 180)] of flockmates
ifelse x-component = 0 and y-component = 0
[ report heading ]
[ report atan x-component y-component ]
end
群集
寻找同伴
如果有的话?羊群
[
寻找最近的邻居
ifelse距离最近邻<最小间隔
[分开]
[对齐
凝聚]]
结束
寻找同伴;;海龟手术
把我的小组安排好
结束
寻找最近的邻居;;海龟手术
将最近的邻居min设置为一个羊群伙伴[与自己保持距离]
结束
;;; 凝聚
凝聚
转向平均航向转向flockmates max cohere转向
结束
报告朝向羊群的平均航向
让x-分量表示配偶的[sin(对我+180)]
让y分量表示群友的[cos(朝向我+180)]
如果x分量=0,y分量=0
[报告标题]
[报告x组件和y组件]
结束
我无法更改的代码,以报告对flockmates的平均航向,因为这里不能使用flockmates的对我自己+180)]。有人能帮我吗