|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
+ n7 X* o" ~! ^' j8 D# W5 y" A. W9 Fto go2 H* ~$ u6 T, v' u% ~
if not any? turtles with [not stopped? ] [ stop ] % l" A7 | H3 ^! a& d9 x' d
ask turtles with [remainder who 5 = 0] [
3 Y# \2 I$ c9 Q$ w: nset close-mates (turtles with [self != myself])with[
& l/ Q9 N0 d& o(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) v5 R! ]+ `0 z4 l, y2 |3 hand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 ]0 K% Z! ]( rand remainder who 5 = 0 2 z; \% o! q: G! w8 g9 L* u
]
; z$ D$ |' Y( |4 K/ J6 Cifelse any? close-mates
* ~2 U6 h1 D* ~) r) }8 F' D[ ) D5 R9 ^& B% Y1 M# ?0 \
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 c: ?0 S5 m+ h/ |# Kface closest-one: \$ x% J0 H& e4 m! [
rt 180
7 }; \) H% ]3 e+ Xfd random-float step-size
O2 M ^5 N* L' @9 l% vavoid-walls: r; Q4 }- \9 J
set stopped? false]
2 O9 d+ s# W% I6 W, n8 Q- `[set stopped? true] C/ {+ j0 ^& l S/ F
] |
|