请问:/ k* }% A v' U% J% f. p' w
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?4 f3 E& X, _! i
4 V* v4 z4 D, ] - s" `7 L1 b" o6 B1 a# _! k1 ]
turtles-own [ energy ]6 D: f# ?& G: z: {- H! F( Y
to setup
7 W- ]7 G( C8 \- wclear-all
& f8 Y$ L5 G# W3 ]" s, ?$ fset-default-shape turtles "square"# u3 R( ?/ q' e5 \ _
crt nutrition
% E) s8 K9 L9 u+ {ask turtles[
3 v! d% A" Y$ E: q set color white
. A* `' E% h& a0 w% O setxy random-pxcor random-pycor]7 f1 i1 T& c7 [ V9 `) O% N
) B9 c6 M' Q8 p( [ask n-of microbes-initialization patches9 ~* ]. T1 @+ m4 o: h/ o/ Z
[ set pcolor green]: b$ V+ k' J/ `5 O
ask turtles [set energy 1]- ?' O+ D0 B1 c5 R% {; n' g$ |$ w/ s
end. ]- N; l2 R# T: b9 b1 k5 G
3 ~& |1 F& u- {to go6 ^) ~' f7 A5 U j5 Z
ask turtles [set heading 90 * random 4 fd 1]6 u9 r- G' }) Q/ M$ w
ask patches with [ any? turtles-here]2 Q2 p7 n! K8 ?2 [/ o0 i5 L" [
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]+ J! A% {( X9 F: D7 R
ask turtles [ if energy = 0 [die ]]7 ^2 x5 {0 F& {. i$ r0 U
end/ b; ] r3 m- g" ?
& h4 q$ |1 Z6 R# ~to tt! t* \; p" o2 v; S R
ask patches [set pcolor gray ]
$ a: r! c C1 t; H# v S- V, Fask turtles [set energy energy - 1]
5 L- e7 j. B% tend$ X0 D+ U) _* e
4 B/ F& y/ E" r6 }7 F* b: D- G
|