请问:; ?5 ?* s* N) ^0 ` c
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
0 r0 c) o; e z+ X
: w) b2 C: M1 f, w0 w
0 ^8 f! H, R7 Xturtles-own [ energy ]
- e0 q& k7 z- [& `$ Q; r' Dto setup
, \( c+ v o, T$ k/ Qclear-all
8 |8 T) H& c" `3 C$ S2 kset-default-shape turtles "square"
* C6 C/ b: ]4 hcrt nutrition# x/ t. J/ P/ [7 X
ask turtles[
0 g& I# x |7 _9 T7 n set color white
' r1 E3 y3 B; r# b# ^$ ` setxy random-pxcor random-pycor]
7 p$ ~6 O& h" Y
! m" r& G3 W5 Oask n-of microbes-initialization patches5 x# p/ R3 M: ~2 P* D1 k
[ set pcolor green]% U7 o( F, P# Q- d0 B# p) p* w% l
ask turtles [set energy 1]
$ a6 h# Y) G6 J" t$ @4 iend
; G& ` X9 Q: D" v" L! H: `& {/ K7 q" u$ `+ w* A: X
to go
3 `& B/ Y- w8 t/ k) q5 R& _/ J' G ask turtles [set heading 90 * random 4 fd 1]
6 \8 |8 ^; d: H! f- H ask patches with [ any? turtles-here]
) }( r! g" ~1 k1 e& d7 l [ if pcolor = green and random 100 < chance-of-congregating [tt ]]4 x( y2 I5 C! j6 [7 g. _
ask turtles [ if energy = 0 [die ]]- l, W8 O0 e. s( q
end
$ g( c) v' c( Q; K' j( x- ?/ Y5 }. c5 z' {( r( E. J6 ?
to tt6 t5 J+ ]5 H8 c7 [' y9 d
ask patches [set pcolor gray ]
# a# i( M' c4 ^% o- @, F$ hask turtles [set energy energy - 1]' d$ l6 z4 W- Z
end H3 S9 c2 j7 R* n; P, e u
: K L& z5 t J3 x! J7 F, x
|