请问:, l& P- e6 S' s, T* R2 t
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
4 E+ _$ t. l# r* a, M4 [8 u1 B
* t- Q/ H& o1 h, [6 j
4 R9 k% P( B) G: jturtles-own [ energy ]* `# P/ }( D, Q. }6 I/ L, b
to setup
5 m% R0 K6 p6 K- q4 Hclear-all
5 W0 }1 [2 X/ H: h9 A, Q- E' bset-default-shape turtles "square"& T3 C0 \0 L3 O
crt nutrition4 P: S0 [! y4 |; y8 X7 c
ask turtles[7 R) h2 m: x, n' s3 i
set color white" n3 V, T0 j, I1 _( d
setxy random-pxcor random-pycor]9 d. x# E1 T5 J: K6 ?4 f
* d7 \, z6 q- _ ^' F
ask n-of microbes-initialization patches2 {8 G7 j0 W. ]/ {2 d2 I% [
[ set pcolor green]% a% Z2 n% H6 Y
ask turtles [set energy 1]
* D# j; C2 h" C4 o$ zend1 D( `& ^8 j2 s9 ?, C6 I
+ z# ?! z) |2 a1 u% s; tto go" p6 r: G& X N9 F
ask turtles [set heading 90 * random 4 fd 1] K- [! s5 g# J& r: Q! s
ask patches with [ any? turtles-here]
- @/ U8 p3 C8 Z8 e [ if pcolor = green and random 100 < chance-of-congregating [tt ]]% s1 [6 D" ]9 n5 m8 O. Q$ q; b. E m' G
ask turtles [ if energy = 0 [die ]]$ Z. f2 }/ F( r5 g1 j
end1 N1 [! f4 s$ J9 ]! [. H$ v% c. V
; [0 ^1 N. Y/ S; D
to tt, |5 D( y" o6 p' ^' W* c+ u
ask patches [set pcolor gray ] N$ x) E. R( f7 z
ask turtles [set energy energy - 1]
6 C G% u$ g. {end
& u8 N- H" ^* G& J8 J9 V$ J
1 ^) Y- @6 M4 q V& L; o' | |