Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netlogo 如何让这些补丁不被海龟/特工攻击?健身房模型。代码已提供但不起作用_Netlogo_Agent Based Modeling - Fatal编程技术网

Netlogo 如何让这些补丁不被海龟/特工攻击?健身房模型。代码已提供但不起作用

Netlogo 如何让这些补丁不被海龟/特工攻击?健身房模型。代码已提供但不起作用,netlogo,agent-based-modeling,Netlogo,Agent Based Modeling,嗨,我想知道是否有人知道不让补丁进入体育馆的确切密码。我关上了所有标有红色斑块的门,黑色斑块就是墙 这里的问题是,我尝试了这些不同的代码,但补丁仍然穿过墙壁。有人能帮我吗 请注意,我一次一个地尝试了这些方法,以确定是否存在任何ff。成功了 能帮助我的人将不胜感激 ask turtles[ ifelse [pcolor] of patch-left-and-ahead 1 1 = red [rt random-float 180 ] [ let f random 5 ifelse [pcolor

嗨,我想知道是否有人知道不让补丁进入体育馆的确切密码。我关上了所有标有红色斑块的门,黑色斑块就是墙

这里的问题是,我尝试了这些不同的代码,但补丁仍然穿过墙壁。有人能帮我吗

请注意,我一次一个地尝试了这些方法,以确定是否存在任何ff。成功了

能帮助我的人将不胜感激

ask turtles[
ifelse [pcolor] of patch-left-and-ahead 1 1 = red [rt random-float 180 ] 
[ let f random 5
ifelse [pcolor] of patch-right-and-ahead 1 1  = black [rt random-float 180 ] 
[ let g random 5

ifelse [pcolor] of  patch-at-heading-and-distance 1 1 = red [rt random-float 180 ] 
[let h  random 5

ifelse [pcolor] of  patch-at-heading-and-distance 1 1  = black [rt random-float 180]          
[let i  random 5

ifelse [pcolor] of  patch-ahead 1  = red [rt random-float 180 ] 
[let h  random 5

ifelse [pcolor] of  patch-ahead 1  = black [rt random-float 180 ] 
[let i  random 5

ifelse [pcolor] of   patch-left-and-ahead 1 1 = red [fd random-float 5]
[fd f]

ifelse [pcolor] of   patch-right-and-ahead 1 1 = red [fd random-float 5]
[fd g]

ifelse  [pcolor] of  patch-at-heading-and-distance 1 1 = red [fd random-float 5]
[fd h]

ifelse  [pcolor] of  patch-at-heading-and-distance 1 1 = black [fd  random-float 5]
[fd i]

ifelse  [pcolor] of  patch-ahead 1  = red [fd random-float 5]
[fd h]

ifelse  [pcolor] of  patch-ahead 1  = black [fd  random-float 5]
[fd i]

]
]
]
]
]
根据要求,以下是修补程序的代码:

to setup-world
set pcolor white

;;FLOOR------------------------------------------------------------------------------
if ( pycor < 91  and pycor > 10) and ( pxcor < 91 and pxcor > 7 ) [ set pcolor 8]
if ( pycor < 90  and pycor > 11) and ( pxcor = 7 ) [ set pcolor 8]
if ( pycor < 89  and pycor > 12) and ( pxcor = 6 ) [ set pcolor 8]
if ( pycor < 88  and pycor > 13) and ( pxcor = 5 ) [ set pcolor 8]
if ( pycor < 87  and pycor > 14) and ( pxcor = 4 ) [ set pcolor 8]
if ( pycor < 86  and pycor > 15) and ( pxcor = 3 ) [ set pcolor 8]
if ( pycor < 85  and pycor > 16) and ( pxcor = 2 ) [ set pcolor 8]
if ( pycor < 84  and pycor > 17) and ( pxcor = 1 ) [ set pcolor 8]
if ( pycor < 83  and pycor > 18) and ( pxcor = 0 ) [ set pcolor 8]
if ( pycor < 82  and pycor > 19) and ( pxcor = -1 ) [ set pcolor 8]
if ( pycor < 81  and pycor > 20) and ( pxcor = -2 ) [ set pcolor 8]
if ( pycor < 80  and pycor > 21) and ( pxcor = -3 ) [ set pcolor 8]
if ( pycor < 79  and pycor > 22) and ( pxcor = -4 ) [ set pcolor 8]
if ( pycor < 78  and pycor > 23) and ( pxcor = -5 ) [ set pcolor 8]
if ( pycor < 77  and pycor > 24) and ( pxcor = -6 ) [ set pcolor 8]
if ( pycor < 76  and pycor > 25) and ( pxcor = -7 ) [ set pcolor 8]
;;basketball -----------------------------------------------------------------------
if ( pycor < 68  and pycor > 33) and ( pxcor < 85 and pxcor > 9  ) [ set pcolor 37]

;;UP --------------------------------------------------------------------------------

if ( pycor = 90 ) and ( pxcor < 85 and pxcor > 7  ) [ set pcolor brown ]

if ( pycor = 88 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 88 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 88 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]


if ( pycor = 86 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]
if ( pycor = 86 ) and ( pxcor < 15 and pxcor > 10  ) [ set pcolor grey ]
if ( pycor = 86 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 84 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]
if ( pycor = 84 ) and ( pxcor < 15 and pxcor > 10  ) [ set pcolor grey ]
if ( pycor = 84 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 82 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]
if ( pycor = 82 ) and ( pxcor < 15 and pxcor > 10  ) [ set pcolor grey ]
if ( pycor = 82 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 80 ) and ( pxcor < 36 and pxcor > 14  ) [ set pcolor brown ]
if ( pycor = 80 ) and ( pxcor < 15 and pxcor > 10  ) [ set pcolor grey ]
if ( pycor = 80 ) and ( pxcor < 81 and pxcor > 60  ) [ set pcolor brown ]
if ( pycor = 80 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 78 ) and ( pxcor < 36 and pxcor > 14  ) [ set pcolor brown ]
if ( pycor = 78 ) and ( pxcor < 15 and pxcor > 10  ) [ set pcolor grey ]
if ( pycor = 78 ) and ( pxcor < 81 and pxcor > 60  ) [ set pcolor brown ]
if ( pycor = 78 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

;;DOWN -------------------------------------------------------------------------

if ( pycor = 11 ) and ( pxcor < 85 and pxcor > 7  ) [ set pcolor brown ]

if ( pycor = 13 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 13 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 13 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 15 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 15 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 15 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 17 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 17 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 17 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 19 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 19 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 19 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 21 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 21 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 21 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

if ( pycor = 23 ) and ( pxcor < 82 and pxcor > 14  ) [ set pcolor brown ]   
if ( pycor = 23 ) and ( pxcor < 15 and pxcor > 10) [ set pcolor grey ]
if ( pycor = 23 ) and ( pxcor < 85 and pxcor > 80) [ set pcolor grey ]

;;CORNER DOWN RIGHT--------------------------------------------------------------------

if ( pycor = 12 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 13 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 14 and pxcor = 5) [ set pcolor brown ]

if ( pycor = 13 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 13 and pxcor = 9) [ set pcolor brown ]

if ( pycor = 14 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 15 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 16 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 15 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 16 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 17 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 18 and pxcor = 7) [ set pcolor brown ]

if ( pycor = 18 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 19 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 20 and pxcor = 8) [ set pcolor brown ]

;;CORNER UP RIGHT---------------------------------------------------------
if ( pycor = 87 and pxcor = 5) [ set pcolor brown ]
if ( pycor = 88 and pxcor = 6) [ set pcolor brown ]
if ( pycor = 89 and pxcor = 7) [ set pcolor brown ] 

if ( pycor = 88 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 88 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 87 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 86 and pxcor = 7) [ set pcolor brown ]
if ( pycor = 85 and pxcor = 6) [ set pcolor brown ]

if ( pycor = 86 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 85 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 84 and pxcor = 8) [ set pcolor brown ]
if ( pycor = 83 and pxcor = 7) [ set pcolor brown ]

if ( pycor = 83 and pxcor = 10) [ set pcolor brown ]
if ( pycor = 82 and pxcor = 9) [ set pcolor brown ]
if ( pycor = 81 and pxcor = 8) [ set pcolor brown ]


;;CENTER CORNER DOWN---------------------------------------------------------------- 
if ( pycor = 29 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 28 and pxcor = 0) [ set pcolor brown ]
if ( pycor = 27 and pxcor = 1) [ set pcolor brown ]

if ( pycor = 29 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 28 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 27 and pxcor = -2) [ set pcolor brown ]
if ( pycor = 26 and pxcor = -1) [ set pcolor brown ]

if ( pycor = 29 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 28 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 27 and pxcor = -5) [ set pcolor brown ]
if ( pycor = 26 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 25 and pxcor = -3) [ set pcolor brown ]

if ( pycor = 26 and pxcor = -7) [ set pcolor brown ]
if ( pycor = 25 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 24 and pxcor = -5) [ set pcolor brown ]

;;CENTER CORNER UP-------------------------------------------------------
if ( pycor = 72 and pxcor = -1) [ set pcolor brown ]
if ( pycor = 73 and pxcor = 0) [ set pcolor brown ]
if ( pycor = 74 and pxcor = 1) [ set pcolor brown ]

if ( pycor = 72 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 73 and pxcor = -3) [ set pcolor brown ]
if ( pycor = 74 and pxcor = -2) [ set pcolor brown ]
if ( pycor = 75 and pxcor = -1) [ set pcolor brown ]

if ( pycor = 72 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 73 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 74 and pxcor = -5) [ set pcolor brown ]
if ( pycor = 75 and pxcor = -4) [ set pcolor brown ]
if ( pycor = 76 and pxcor = -3) [ set pcolor brown ]

if ( pycor = 75 and pxcor = -7) [ set pcolor brown ]
if ( pycor = 76 and pxcor = -6) [ set pcolor brown ]
if ( pycor = 77 and pxcor = -5) [ set pcolor brown ]




;;center -------------------------------------------------------------------------
if ( pxcor = -8 ) and ( pycor < 75 and pycor > 26  ) [ set pcolor brown ]

if ( pxcor = -6 ) and ( pycor < 67 and pycor > 34  ) [ set pcolor brown ]
if ( pxcor = -6 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = -6 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]

if ( pxcor = -4 ) and ( pycor < 67 and pycor > 34  ) [ set pcolor brown ]
if ( pxcor = -4 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = -4 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]

if ( pxcor = -2 ) and ( pycor < 67 and pycor > 34  ) [ set pcolor brown ]
if ( pxcor = -2 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = -2 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]

if ( pxcor = 0 ) and ( pycor < 47 and pycor > 34  ) [ set pcolor brown ]
if ( pxcor = 0 ) and ( pycor < 67 and pycor > 54  ) [ set pcolor brown ]
if ( pxcor = 0 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = 0 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]

if ( pxcor = 2 ) and ( pycor < 62 and pycor > 54  ) [ set pcolor brown ]
if ( pxcor = 2 ) and ( pycor < 47 and pycor > 38  ) [ set pcolor brown ]
if ( pxcor = 2 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = 2 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]

if ( pxcor = 4 ) and ( pycor < 62 and pycor > 54  ) [ set pcolor brown ]
if ( pxcor = 4 ) and ( pycor < 47 and pycor > 38  ) [ set pcolor brown ]
if ( pxcor = 4 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = 4 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]


if ( pxcor = 6 ) and ( pycor < 62 and pycor > 54  ) [ set pcolor brown ]
if ( pxcor = 6 ) and ( pycor < 47 and pycor > 38  ) [ set pcolor brown ]
if ( pxcor = 6 ) and ( pycor < 35 and pycor > 29  ) [ set pcolor grey ]
if ( pxcor = 6 ) and ( pycor < 72 and pycor > 66  ) [ set pcolor grey ]   

;;WaLL----------------------------------------------------------------------

if ( pycor = 10 ) and ( pxcor < 85 and pxcor > 7  ) [ set pcolor black ]
if ( pycor = 91 ) and ( pxcor < 85 and pxcor > 7  ) [ set pcolor black ]

if ( pxcor = -9 ) and ( pycor < 76 and pycor > 25  ) [ set pcolor black ]

if ( pxcor = 91 ) and ( pycor < 34 and pycor > 9  ) [ set pcolor black ]
if ( pxcor = 91 ) and ( pycor < 92 and pycor > 67  ) [ set pcolor black ]

;;stage
if ( pxcor = 98) and ( pycor < 68 and pycor > 33  ) [ set pcolor black ]
if ( pycor = 33 ) and ( pxcor < 99 and pxcor > 91  ) [ set pcolor black ]
if ( pycor = 68 ) and ( pxcor < 99 and pxcor > 91  ) [ set pcolor black ]


if ( pycor = 11 and pxcor = 7) [ set pcolor black ]
if ( pycor = 12 and pxcor = 6) [ set pcolor black ]
if ( pycor = 13 and pxcor = 5) [ set pcolor black ]
if ( pycor = 14 and pxcor = 4) [ set pcolor black ]
if ( pycor = 15 and pxcor = 3) [ set pcolor black ]

if ( pycor = 22 and pxcor = -4) [ set pcolor black ]
if ( pycor = 23 and pxcor = -5) [ set pcolor black ]
if ( pycor = 24 and pxcor = -6) [ set pcolor black ]
if ( pycor = 25 and pxcor = -7) [ set pcolor black ]
if ( pycor = 26 and pxcor = -8) [ set pcolor black ]


if ( pycor = 90 and pxcor = 7) [ set pcolor black ]
if ( pycor = 89 and pxcor = 6) [ set pcolor black ]
if ( pycor = 88 and pxcor = 5) [ set pcolor black ]
if ( pycor = 87 and pxcor = 4) [ set pcolor black ]
if ( pycor = 86 and pxcor = 3) [ set pcolor black ]  

if ( pycor = 79 and pxcor = -4) [ set pcolor black ]
if ( pycor = 78 and pxcor = -5) [ set pcolor black ]
if ( pycor = 77 and pxcor = -6) [ set pcolor black ]
if ( pycor = 76 and pxcor = -7) [ set pcolor black ]
if ( pycor = 75 and pxcor = -8) [ set pcolor black ]

;;stage--------------------------------------------------------------------------------  
if ( pycor < 68  and pycor > 33) and ( pxcor < 98 and pxcor > 90  ) [ set pcolor 37 ]

;;lines-------------------------------------------------------------------------------
if ( pycor = 66 ) and ( pxcor < 82 and pxcor > 11 ) [ set pcolor yellow ]
if ( pycor = 35 ) and ( pxcor < 82 and pxcor > 11 ) [ set pcolor yellow ]
if ( pxcor = 12 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]
if ( pxcor = 82 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]
if ( pxcor = 47 ) and ( pycor < 67 and pycor > 34 ) [ set pcolor yellow ]

;;gates are closed initially ---------------------------------------------------------- 
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower left, right door

if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower right, right door

if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door

if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door

if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower left, right door

if lower-left = "Half"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower left, right door
]

if lower-left = "Close"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower left, right door
]
;;-------------------------------------------------------------------------------------

;; lower right------------------------------------------------------------------------- 
if lower-right = "Open"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower right, right door
]

if lower-right = "Half"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower right, right door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower right, left door
]

if lower-right = "Close"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower right, right door
]
;;-------------------------------------------------------------------------------------

;; upper left--------------------------------------------------------------------------
if upper-left = "Open"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor green ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor green ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor green ] ; upper left , left door
]

if upper-left = "Half"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]

if upper-left = "Close"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
;; ------------------------------------------------------------------------------

;; upper right-------------------------------------------------------------------
if upper-right = "Open"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor green ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor green ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor green ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , left door
]

if upper-right = "Half"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , left door 
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , left door 
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , left door 
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , right door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , right door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , right door
]

if upper-right = "Close"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door
]   
;; ----------------------------------------------------------------------------

end    


to setupgate

ask patches [

;;exits--------------------------------------------------------------------------------
;; Point of view is when the agents are outside the Gymnasium.
;; lower left--------------------------------------------------------------------------
if lower-left = "Open"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower left, right door
]

if lower-left = "Half"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower left, right door
]

if lower-left = "Close"
[
if ( pycor = 10 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower left, left door
if ( pycor = 10 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower left, right door
]
;;-------------------------------------------------------------------------------------

;; lower right-------------------------------------------------------------------------
if lower-right = "Open"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor green ] 
; lower right, right door
]

if lower-right = "Half"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor green ] 
; lower right, right door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower right, left door
]

if lower-right = "Close"
[
if ( pycor = 91 ) and ( pxcor < 88 and pxcor > 84  ) [ set pcolor red ] 
; lower right, left door
if ( pycor = 91 ) and ( pxcor < 91 and pxcor > 87  ) [ set pcolor red ] 
; lower right, right door
]
;;-------------------------------------------------------------------------------------

;; upper left--------------------------------------------------------------------------
if upper-left = "Open"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor green ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor green ] ; upper left , left door 
if ( pycor = 21 and pxcor = -3) [ set pcolor green ] ; upper left , left door
]

if upper-left = "Half"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor green ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor green ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor green ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]

if upper-left = "Close"
[
if ( pycor = 16 and pxcor = 2) [ set pcolor red ] ; upper left  , right door
if ( pycor = 17 and pxcor = 1) [ set pcolor red ] ; upper left  , right door
if ( pycor = 18 and pxcor = 0) [ set pcolor red ] ; upper left  , right door
if ( pycor = 19 and pxcor = -1) [ set pcolor red ] ; upper left , left door
if ( pycor = 20 and pxcor = -2) [ set pcolor red ] ; upper left , left door
if ( pycor = 21 and pxcor = -3) [ set pcolor red ] ; upper left , left door
]
;; ------------------------------------------------------------------------------

;; upper right-------------------------------------------------------------------
if upper-right = "Open"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor green ] ; upper right , right door
if ( pycor = 84 and pxcor = 1) [ set pcolor green ] ; upper right , right door
if ( pycor = 83 and pxcor = 0) [ set pcolor green ] ; upper right , right door
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , left door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , left door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , left door
]

if upper-right = "Half"
[
if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , left door 
if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , left door 
if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , left door 
if ( pycor = 82 and pxcor = -1) [ set pcolor green ] ; upper right , right door
if ( pycor = 81 and pxcor = -2) [ set pcolor green ] ; upper right , right door
if ( pycor = 80 and pxcor = -3) [ set pcolor green ] ; upper right , right door
]

 if upper-right = "Close"
 [
 if ( pycor = 85 and pxcor = 2) [ set pcolor red ] ; upper right , right door
 if ( pycor = 84 and pxcor = 1) [ set pcolor red ] ; upper right , right door
 if ( pycor = 83 and pxcor = 0) [ set pcolor red ] ; upper right , right door
 if ( pycor = 82 and pxcor = -1) [ set pcolor red ] ; upper right , left door
 if ( pycor = 81 and pxcor = -2) [ set pcolor red ] ; upper right , left door
 if ( pycor = 80 and pxcor = -3) [ set pcolor red ] ; upper right , left door
 ]   
 ;; ----------------------------------------------------------------------------

 ]

 end    
设置世界
将颜色设置为白色
;;地板------------------------------------------------------------------------------
如果(pycor<91和pycor>10)和(pxcor<91和pxcor>7)[设置pcolor 8]
如果(pycor<90和pycor>11)和(pxcor=7)[设置pcolor 8]
如果(pycor<89和pycor>12)和(pxcor=6)[设置pcolor 8]
如果(pycor<88和pycor>13)和(pxcor=5)[设置pcolor 8]
如果(pycor<87和pycor>14)和(pxcor=4)[设置pcolor 8]
如果(pycor<86和pycor>15)和(pxcor=3)[设置pcolor 8]
如果(pycor<85和pycor>16)和(pxcor=2)[设置pcolor 8]
如果(pycor<84和pycor>17)和(pxcor=1)[设置pcolor 8]
如果(pycor<83和pycor>18)和(pxcor=0)[设置pcolor 8]
如果(pycor<82和pycor>19)和(pxcor=-1)[设置pcolor 8]
如果(pycor<81和pycor>20)和(pxcor=-2)[设置pcolor 8]
如果(pycor<80和pycor>21)和(pxcor=-3)[设置pcolor 8]
如果(pycor<79和pycor>22)和(pxcor=-4)[设置pcolor 8]
如果(pycor<78和pycor>23)和(pxcor=-5)[设置pcolor 8]
如果(pycor<77和pycor>24)和(pxcor=-6)[设置pcolor 8]
如果(pycor<76和pycor>25)和(pxcor=-7)[设置pcolor 8]
;;篮球-----------------------------------------------------------------------
如果(pycor<68和pycor>33)和(pxcor<85和pxcor>9)[设置pcolor 37]
;;向上--------------------------------------------------------------------------------
如果(pycor=90)和(pxcor<85和pxcor>7)[设置pcolor棕色]
如果(pycor=88)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=88)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=88)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=86)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=86)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=86)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=84)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=84)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=84)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=82)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=82)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=82)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=80)和(pxcor<36和pxcor>14)[设置pcolor棕色]
如果(pycor=80)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=80)和(pxcor<81和pxcor>60)[设置pcolor棕色]
如果(pycor=80)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=78)和(pxcor<36和pxcor>14)[设置pcolor棕色]
如果(pycor=78)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=78)和(pxcor<81和pxcor>60)[设置颜色为棕色]
如果(pycor=78)和(pxcor<85和pxcor>80)[设置pcolor灰色]
;;向下-------------------------------------------------------------------------
如果(pycor=11)和(pxcor<85和pxcor>7)[设置颜色为棕色]
如果(pycor=13)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=13)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=13)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=15)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=15)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=15)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=17)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=17)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=17)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=19)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=19)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=19)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=21)和(pxcor<82和pxcor>14)[设置颜色为棕色]
如果(pycor=21)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=21)和(pxcor<85和pxcor>80)[设置pcolor灰色]
如果(pycor=23)和(pxcor<82和pxcor>14)[设置pcolor棕色]
如果(pycor=23)和(pxcor<15和pxcor>10)[设置pcolor灰色]
如果(pycor=23)和(pxcor<85和pxcor>80)[设置pcolor灰色]
;;右下角--------------------------------------------------------------------
如果(pycor=12和pxcor=7)[设置pcolor棕色]
如果(pycor=13和pxcor=6)[设置pcolor棕色]
如果(pycor=14和pxcor=5)[设置pcolor棕色]
如果(pycor=13和pxcor=10)[设置pcolor棕色]
如果(pycor=13和pxcor=9)[设置pcolor棕色]
如果(pycor=14和pxcor=8)[设置pcolor棕色]
如果(pycor=15和pxcor=7)[设置pcolor棕色]
如果(pycor=16和pxcor=6)[设置pcolor brown]
如果(pycor=15和pxcor=10)[设置pcolor棕色]
如果(pycor=16和pxcor=9)[设置pcolor棕色]
如果(pycor=17和pxcor=8)[设置pcolor棕色]
如果(pycor=18和pxcor=7)[设置pcolor棕色]
如果(pycor=18和pxcor=10)[设置pcolor棕色]
如果(pycor=19和pxcor=9)[设置pcolor棕色]
如果(pycor=20和pxcor=8)[设置pcolor棕色]
;;
turtles-own
[closest-door]

to setup 
....

create-turtles [

.....
    set closest-door min-one-of patches with [pcolor = green][ distance myself] ; nearest door
    set closest-door  one-of patches with [pcolor = green] ; any open door


]


to go
  ask turtles
  [move-toward-gym  closest-door random 5]
end
to move-toward-gym [my-door walking-speed]
  if my-door!= nobody [
face my-door
let possible-moves patches with [distance myself = walking-speed and pcolor = white]
let t min-one-of possible-moves [distance my-door]

if t != nobody [move-to t ]
]
end
turtles-own
[closest-door

]

globals 
[lower-left
  lower-right
  upper-left
  upper-right
  ]


to setup
  clear-all
 movie-cancel
  movie-start "out.mov"
  ask patches [setup-world]
  set lower-left "Open"
    set lower-right "Open"
    set upper-left "Open"
    set upper-right "Open"
    set upper-left "Open"
  create-turtles 100  [
 set size 2

    move-to one-of patches with [
     pcolor = white


    ]
    set closest-door min-one-of patches with [pcolor = green][ distance myself] ; nearest door
    set closest-door  one-of patches with [pcolor = green] ; any open door



  ]
reset-ticks
end

to go

      if ticks < 50 
  [
  movie-grab-view
  ]


  ask turtles  
  [move-toward-gym  closest-door random 5]

  if ticks = 50 [movie-close]

  tick
end
to move-toward-gym [my-door walking-speed]
  if my-door != nobody
  [
face my-door
let possible-moves patches with [distance myself = walking-speed and pcolor = white]
let t min-one-of possible-moves [distance my-door]
ifelse  t != nobody [move-to t] []

if any? patches with [distance myself = walking-speed and pcolor = green]
[move-to one-of patches with [pcolor = green]
  ]]
end