|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: H" d) s- F# W8 S/ ?" hto go
5 e% r. @* D: Mif not any? turtles with [not stopped? ] [ stop ] / \& {4 ?' @0 N) n3 c( h
ask turtles with [remainder who 5 = 0] [ U, O1 |8 j9 B3 |1 p
set close-mates (turtles with [self != myself])with[! n W: g6 k2 J( n% g* `
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - X; f; d7 H0 S
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ) `# c" A, w: c% l) Z4 ]4 @
and remainder who 5 = 0 2 [! U0 b/ \( [9 P
] 3 n8 U6 h9 R$ E
ifelse any? close-mates : F1 U8 U, B) C* f# @
[
: i; \* n$ T4 X1 @5 h- qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ u1 Q+ y9 p- j* ]* X
face closest-one6 y G: M3 Z+ C9 B8 N
rt 180
5 s/ `/ \0 J7 Nfd random-float step-size4 e; ?9 V: J7 ?3 Y- F
avoid-walls/ {0 _1 |' C' D+ F4 i: A7 D
set stopped? false]
A1 ^$ G3 a' O0 C[set stopped? true]
5 i, g& W' c8 I: \+ ?2 c% H] |
|