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出去,那就是斜方向不允许,因为邻居会占用补丁不在里面“ - 不能对这句话有任何意义 –
抱歉,英文不是我的品质。 – user3780602
海龟从补丁10 0退出,在同样的pycor出口修补,所以ycor = 0,而不是从补丁10 1或10 -1开始,就像代码示例中那样。 – user3780602