|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! p& n- H0 \3 Mto go
& f a; N6 x; p5 Q2 ~8 P) e# Z& Xif not any? turtles with [not stopped? ] [ stop ]
+ }) p" Y( V1 J1 K/ Mask turtles with [remainder who 5 = 0] [; }4 ]. u9 _# D# k
set close-mates (turtles with [self != myself])with[: n9 a% a/ a; r9 C5 g. d
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% E. h& [# z1 X, Z) }# aand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 u& g3 z2 j& n7 X+ k4 Fand remainder who 5 = 0
U. t6 O3 Z- h4 `]
7 T& t; g2 L' Y% _5 H! @$ Y0 Bifelse any? close-mates " }7 N# P5 O; F5 G- {; b
[ 2 L+ N8 l8 z7 Y. ~9 E; v6 [
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]8 U% u D/ z7 b+ C/ V
face closest-one/ [1 R. R# ] ^5 u, b* K
rt 180
" J# Q; [; s0 G, O+ K2 cfd random-float step-size
6 _( W% ~# c1 k. X: x& uavoid-walls3 v0 f6 b+ Y' D/ O. K9 R
set stopped? false]5 q* w! r9 x2 ^: W
[set stopped? true] : v: U! Q3 X m+ V
] |
|