请问:" V& ]: u/ Z# R
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?( r9 H) l: W7 R, ]& I. Z% X
. u* \+ G7 ?% P' t* `1 D
, [# \# b* Q2 N8 b. s3 u4 `turtles-own [ energy ]
1 q3 f4 W/ Z; S2 v: P: ?to setup
7 d& U. J; q8 q Dclear-all( O( W( o5 x, ] C% \$ y2 A
set-default-shape turtles "square"
; M: r% X- `" C7 {5 Ucrt nutrition
, n7 r5 E3 ^6 A8 E. Nask turtles[1 J* G ~1 M+ M/ ^/ w
set color white
: T3 p' W( i6 L' ^6 t% j2 i setxy random-pxcor random-pycor]
9 {! O; v- J) _* ` 2 z" }! a' t7 p# t. o
ask n-of microbes-initialization patches. v9 ^6 t1 f3 u' \/ U
[ set pcolor green]7 o$ V' c4 H# K, e
ask turtles [set energy 1]/ G: t6 [: \! S2 y8 a& `+ j
end
9 h# E5 X4 ~( o* v9 e1 V+ y% N. a& y* _$ m/ t3 `# d
to go
# h5 R" k# D& @8 {" L$ n- W ask turtles [set heading 90 * random 4 fd 1], O) d8 t U T; s
ask patches with [ any? turtles-here]& s' r, P+ J! C- z# Q! [: w
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
7 l- c1 W: N( r ask turtles [ if energy = 0 [die ]]
0 C, s5 D( `& i5 }6 x end
8 ^, T" `8 X( h) g
7 b6 P o$ {/ a. c' q" z4 xto tt
3 V" t3 w2 N6 V' b# S2 ~ask patches [set pcolor gray ]
( \( f8 ?5 C& T5 dask turtles [set energy energy - 1]
& I0 r1 C( ]( T. D1 H. Eend8 S( h' Z# f) Z. [) I
* j8 Z" W3 y$ U1 E8 _+ n" Z b
|