请问:7 M$ X0 c1 \2 m* o' P: }
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?6 h0 a. q y* C! @
: y b. E4 T3 p) I 9 I+ D" W/ p# E3 l8 D
turtles-own [ energy ]/ G6 v' l& o- @; U$ G( Q+ ~
to setup
$ V' O& d) N& O4 d! \$ P5 q5 g8 p5 }9 zclear-all
& d. U2 o( K" Y7 N( U) Y4 g+ ^+ @set-default-shape turtles "square"
' t- `' t3 `! L& F% bcrt nutrition! ^: {4 w. T# _* s/ @8 U, q' c( V; S
ask turtles[
# u/ s/ s5 _9 a3 T8 W set color white
7 i3 o) w) Z( A) T9 L0 K setxy random-pxcor random-pycor]
! i" m( I/ m3 }/ m9 l
' U: ~8 L4 K$ _ t- d- O( d; S7 Zask n-of microbes-initialization patches
! g4 ]. p) E1 r [ set pcolor green]
4 H9 o# z. C; g9 Q" m. I+ s0 f0 f ask turtles [set energy 1]
0 \* ~4 m" G. oend
4 G o+ j+ _& I6 J' G, V
% V$ Y5 S) A# I& Q+ F' ]0 ~to go
# p4 F' a Y' K: O5 T: M3 C# H6 M) [$ } ask turtles [set heading 90 * random 4 fd 1]
7 e0 I& G5 o2 F2 h& |" G( w' u ask patches with [ any? turtles-here]8 X3 I" G' G. g( K
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
8 @# G. u! d& Y4 ]8 ` ask turtles [ if energy = 0 [die ]]
4 {: v. p3 w; z end8 H( y3 P7 [4 v' ]: q
2 I9 _8 N$ Z5 d+ H9 r1 k
to tt
9 F$ c0 k5 s- Q. R* v/ vask patches [set pcolor gray ]
) M; y$ @% y) t8 o. `ask turtles [set energy energy - 1]
* L, Z7 I: r- E, M/ ]' B( n% ]! {5 c5 cend) I; a. R6 j1 p$ P) w' L
( S1 G8 j" r: y0 R, l- T: f |