请问:
z" Z, e( {. ]- r0 J1 [+ `; c随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% y4 ^# Y1 o& [. w2 g% f) {5 \( j
- R- U. `! b. u9 t: @ U+ i. [( r& P" E# L! I
turtles-own [ energy ]
; G! R4 K- `7 T, jto setup
$ W3 A# F$ b i5 A8 _clear-all9 [& U2 L( I# K y' l
set-default-shape turtles "square". y: G' x" y1 B5 H' W6 C6 U' W$ P
crt nutrition$ [: L7 Q5 y& i
ask turtles[ j( E, [1 k3 P7 ?
set color white
: N2 g/ u- a0 y$ C1 Z setxy random-pxcor random-pycor]
) H, |( B6 _1 N$ T' o( y/ i: z - j% k4 U9 x2 i0 u. ~4 s) R
ask n-of microbes-initialization patches
+ P g3 |4 n& t: u$ @ [ set pcolor green]
, B, U* n+ t' F ask turtles [set energy 1]
$ e$ r. x9 \4 T ~; V5 m1 Nend+ G8 x8 y2 I; J! M0 M
* _4 G/ [3 y; O0 X
to go
" a1 _& m$ F& ^2 k* I ask turtles [set heading 90 * random 4 fd 1], |& h( G3 [6 _; a
ask patches with [ any? turtles-here]
1 R/ P/ C. F9 b0 z: P [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
$ O8 j, _6 j$ S9 l/ S1 d ask turtles [ if energy = 0 [die ]]
, y" ^9 f5 V: W5 b end
5 \; @' \& d: d9 ]& B4 _7 b i+ z" L
& J0 [" K! ]( G5 W9 a; Kto tt
" h& d' _1 K d* W$ Gask patches [set pcolor gray ]- y3 I8 W. t' W) B% L; x
ask turtles [set energy energy - 1]* b. Q2 U7 y+ o, {0 y
end
- `! n* W' H- x1 W0 x
# n+ p- F+ _; N" q8 R' l/ B |