请问:
" s8 G4 l( I! i) R9 B8 W随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?1 s, u) P* }; L c* ?" Y$ V1 I
- T% Y( b% e$ Y; {* `) V6 d
0 U8 s1 }" b! [3 B6 n* |0 j; y
turtles-own [ energy ]' t& V+ u. n1 d0 I- K* E
to setup
# V7 Q7 U: Y1 Y: w# f" xclear-all
" P- `! S3 L$ k$ s* sset-default-shape turtles "square"
3 k7 Q- |$ Q8 k5 y& Z: H( Acrt nutrition
) {* m) @5 o; X0 i( Sask turtles[- ?4 a6 A9 l4 m% t8 c1 d) Z* v. X- k
set color white
' \) c3 h7 `( ^" J( P setxy random-pxcor random-pycor]
! L; q3 T- a: A" h
* c* f6 U7 O; M) f1 s/ h: pask n-of microbes-initialization patches
, \8 F; z/ M8 N! ?7 L. \ [ set pcolor green]) X4 l2 Z1 n& M0 c" Y \' w' v
ask turtles [set energy 1]3 E1 h% p6 Z; V8 Y
end9 R6 m. I; K" m2 v2 _
( i( M0 d: S' f" F$ _3 Eto go" l1 ~( U( X8 ?% P- @
ask turtles [set heading 90 * random 4 fd 1]
7 b9 r6 n v- c; M% o0 c! x3 A ask patches with [ any? turtles-here]
7 c9 H& h5 G3 P [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
2 n3 f7 U' H* b ask turtles [ if energy = 0 [die ]]
6 z6 t, `- ~ W; u; Q" _, _4 `2 E- ~ end# v% ~0 m' t1 j. V* P) o
6 Q6 y" t7 A) G0 X5 p% }; d/ }to tt; a- ?! x. l/ w( [
ask patches [set pcolor gray ]+ V+ y6 q) z, O' z& J
ask turtles [set energy energy - 1]& b* R+ D: x# D& Z7 n- l& _0 X
end" u/ P) u' b* c4 e$ [# l
. Y5 a, `+ U! v( Z T
|