|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" P, p2 `/ G" u, k: `( bto go' }( A: Y! Q/ O( N
if not any? turtles with [not stopped? ] [ stop ]
' l, P o, o7 d6 z4 Pask turtles with [remainder who 5 = 0] [2 w. f# `1 J# Q0 b' B5 I' ^
set close-mates (turtles with [self != myself])with[
7 n3 F8 C# N0 @* Q- j, F(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - a/ G' K2 |% M% K: s1 B$ `
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 x) ?" N" F- j: C7 y6 [
and remainder who 5 = 0 ( i a7 o" `6 h9 _7 o
] : u; o% U% {( n; m0 Z- L
ifelse any? close-mates
+ e& ^8 I6 W! e, C! W2 u[ * S' {( h$ m) x9 m
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]) K* T5 E. Y$ ?) g/ p
face closest-one) R( G' J' m' C: c
rt 180
# D3 J$ Z* E! R3 S0 R" j0 pfd random-float step-size
y& v# U2 n( V4 [avoid-walls* P$ Z# ?' R( d# F
set stopped? false]
B$ b; M5 ~* P9 H4 F' Y& ?/ a, E[set stopped? true] 9 I/ e. e; d; n
] |
|