|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
7 t6 W0 Q1 v2 U, _2 Kto go
- ?* w, O( |, ~- Sif not any? turtles with [not stopped? ] [ stop ] 4 D; B& j+ G+ z; N% x* d* f! m
ask turtles with [remainder who 5 = 0] [
1 ?% E/ m8 O. S3 Hset close-mates (turtles with [self != myself])with[
! }) d5 x2 A( z- b( ^: K9 U(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
: p2 n( v. } V/ r; uand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
; G$ H/ S- M" O4 C6 c) oand remainder who 5 = 0
( O+ c2 K- i9 B$ Y0 L! {& t" N]
" c+ P) \, q# difelse any? close-mates # f" i( b N% ?! |8 v2 J) H9 S* k
[ 7 ~: f8 u: ?+ h5 y
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]4 q7 \. U$ o& ] y' W0 a- J
face closest-one
/ p, Y5 U, R, v# d/ ]rt 180/ e, t, y+ U/ N ?/ z, z
fd random-float step-size
7 a. H' r+ V: Z4 j5 ^3 navoid-walls
/ q$ B+ ^6 P. `: y; hset stopped? false]: Y" W& q* G6 h; s
[set stopped? true]
j2 i& }) C0 `] |
|