【发布时间】:2014-07-06 21:08:19
【问题描述】:
to setup
ca
reset-ticks
ask patches [
set inside? (abs pycor < 10 and abs pxcor < 10)
set exit? false
ask patch 11 0 [ set pcolor lime set exit? true]
]
repeat initial-population [ ; start condition turtles with any other turtles on neighbors
ask one-of patches with [
inside? and (not any? other turtles-here) and (not any? turtles-on neighbors)] [
sprout 1 [
set color blue
set size 1
]]]
end
to go
tick
define-neighbors-radius-2
move
end
to define-neighbors-radius-2
ask turtles [
set neighbors-ahead2 patches at-points [[2 1] [2 0] [2 -1]]
set neighbors-for-y-up2 patches at-points [[2 0] [2 -1] [1 -2] [0 -2] [-1 -2]] with [inside?]
set neighbors-for-y-down2 patches at-points [[-1 2] [0 2] [1 2] [2 1] [2 0]] with [inside?]
]
end
to move
;; my intent to move turtles to exit without their neighbors are occupied by other turtles, ;;that is the 8 patches around turtles are empty until exit?
ask turtles[
ifelse inside? [
if ycor = 0 [ ;strategy to turtles with in front exit
ifelse exit? [
set heading 90
fd .5
]
[
facexy 11 0
if (not any? turtles-on neighbors) and (not any? turtles-on neighbors-ahead2) [
fd .5
]
]
]
if ycor > 0 [ ; strategy to turtles occupied "bottom-side" of inside?
facexy 11 0
if (not any? turtles-on neighbors) and (not any? turtles-on neighbors-for-y-up2) [
fd .5
]
]
if ycor < 0 [ ; strategy to turtles occupied "down-side" of inside?
facexy 11 0
if (not any? turtles-on neighbors) and (not any? turtles-on neighbors-for-y-down2) [
fd .5
]
]
]
[
set heading 90
fd .5
]
]
end
我尝试移动海龟退出,但不是所有海龟都移动,为什么? 此外,海龟必须在 ycor = 0 的情况下外出,即不允许倾斜方向,因为邻居将占据的补丁不在里面! 不能公开这个问题,因为“看起来我的帖子主要是代码”,所以谈谈我的生活: 说真的,我的意图是在出口前创建一个人群并设置一些规则来延迟海龟流出口,为此我需要邻居空着来显示代理之间的交互。 (也接受一些设置此交互的建议)但此时海龟到达出口! 谢谢
【问题讨论】:
-
"另外,海龟必须在 ycor = 0 的情况下出去,这是不允许的倾斜方向,因为邻居将占用的补丁不在里面" — 无法理解这句话
-
抱歉英语不是我的素质。
-
海龟从补丁 10 0 退出,补丁在相同的 pycor 退出,所以 ycor = 0,而不是像代码示例中那样从补丁 10 1 或 10 -1 退出。
-
您可以编辑您的原始问题以使其更清晰。
标签: netlogo