当紧急情况发生时,我试图让一名特工(白人)跟随领导(黑人)。问题是,当紧急情况发生时,智能体会跟随领导者,然而他们彼此重叠。如何确保它们在跟随领导者时不会相互重叠。我确实尝试过在work.Really中使用分离规则,它不需要知道如何解决这个问题。谢谢你的帮助
turtles-own
[
leader?
leader
]
to setup
clear-all
reset-ticks
ask n-of population patches with [ pcolor = blue]
[sprout 1
[ set color white
set size 1
set shape "person"
set leader? false]]
choose-leaders
end
to choose-leaders
ask n-of ((percent_of_leader / 100) * population ) turtles
[
set leader? true
set color black
set size 1
set shape "person"
set leader self
]
end
to go
ask turtles [follow-leader]
tick
end
to follow-leader
if not leader? [
let nearby-leaders turtles with [leader? and distance myself < 3]
if any? nearby-leaders
[ set heading (towards min-one-of nearby-leaders [distance myself]) - random minimum-separation + random minimum-separation
]]
end 发布于 2014-10-11 22:17:32
正确的格式:
while other turtles here [fd 1]是:
while any? other turtles-here [fd 1]确切地说,这不是最小间隔规则。这确保了海龟将继续移动,直到它不再与任何其他海龟共享一块土地。但是,如果这两只海龟靠近斑块边界,但在相反的两侧,那么这只海龟可能仍然随意地靠近另一只海龟。尽管如此,对于您的目的来说,它可能已经足够好了。
海龟以均匀的距离跟随领导者的一个示例模型是追随者(或多或少?不确定如何统一),在样本模型的艺术部分,在NetLogo的模型库中。您可能会查看该模型,看看您是否认为该方法适用于您的问题。
https://stackoverflow.com/questions/26275090
复制相似问题