请问:+ t* K. q: q( G) f) g- P
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
4 f: H- t# [ `) N: v2 \9 _$ O! g$ @, ~; J1 f
8 B% r6 K& O. P' U- K
turtles-own [ energy ]
/ Y1 A; k! Y( U9 H& R+ P7 uto setup
5 q/ e l/ ]0 H4 Lclear-all
" E' l+ c% d& a& i* d2 jset-default-shape turtles "square"" d, e' I5 q7 y+ T0 F
crt nutrition
* p7 }, _6 q3 L4 B% P4 k" v# z& uask turtles[* c) T4 T, z; Y; k% B
set color white& L1 p4 T% Z% u H( m+ A
setxy random-pxcor random-pycor]) @1 h# p! b; M# f( v( N
- q0 e) E9 @3 O3 w0 |" K% kask n-of microbes-initialization patches
: O5 J2 L; g* a! F0 x" S [ set pcolor green]
) Z. g: z: `+ ]/ R( m6 ~! s( l ask turtles [set energy 1]
# b* Q; C1 q aend: j, r3 _" A; _. z
( o. G( ^5 _+ f- i, K) Mto go1 J4 w: t/ S. h4 R3 W
ask turtles [set heading 90 * random 4 fd 1]
" j2 r% R0 m& o1 n3 P ask patches with [ any? turtles-here]/ O" V& e/ }1 Q# ~$ l! N
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]2 t$ E+ r5 q; w9 T* o. A: J; Q
ask turtles [ if energy = 0 [die ]]
. \- A9 R4 O3 L7 a5 ]5 H; x end
4 M- o/ {5 W6 P& g6 M0 f& W) w* R8 S: S4 C: e
to tt
/ X9 H+ W' M% T$ H* L7 U! h( ~ask patches [set pcolor gray ]$ k' b5 J: M$ m! o1 p: `
ask turtles [set energy energy - 1]
' j8 h. H# r5 E3 u! Q! cend
( c2 j, x: P+ r& `0 K0 O+ Y6 X: C% b% y; Q1 ]6 {
|