请问:+ A- ^4 ^3 B. m u2 @! i4 \
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?" h1 v+ M1 d) [) X/ m+ V( q- A& w
2 [6 m$ Y* l" z ( s8 w. [# w5 l7 a
turtles-own [ energy ]; i9 v! V) q, w2 J9 |
to setup! x7 P- b6 [; Q4 D/ b7 `( l
clear-all
( X3 c" T6 N& `set-default-shape turtles "square"
" f+ |: V- o3 f; jcrt nutrition
" N' {% H3 c }6 I. Iask turtles[
5 e1 I" ^8 M& F _' p set color white
/ @7 J- S: I0 a setxy random-pxcor random-pycor]
* a6 I" J7 j ^6 v+ K . R' _% h8 `# b
ask n-of microbes-initialization patches K$ ^, h: a( ~, c5 C) Q% a/ i3 x
[ set pcolor green]4 q$ e0 ?0 ?2 \" i/ G
ask turtles [set energy 1]9 o3 [; b' I& }) [4 n: n3 `
end. J1 [* L2 h6 ]2 K5 e* X
& O5 d- ?: I# p* L/ `; F5 t
to go( s8 @1 A/ ]% |2 w# [: m1 N/ s9 J
ask turtles [set heading 90 * random 4 fd 1]
" E: W1 G/ g# ?9 {1 O4 O4 W ask patches with [ any? turtles-here]
! h: o+ o( B% n0 |# d _ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% k: Y$ Y+ u6 A$ f I# z ask turtles [ if energy = 0 [die ]]' u7 g s, R0 u8 K( `) B, ?
end
7 V7 N9 F. @- ^( }
~$ c) S; h+ ]$ o# u" _to tt
( W2 d; ^+ W9 F$ rask patches [set pcolor gray ]8 |0 D4 _, ~% p
ask turtles [set energy energy - 1]0 `/ k* ?9 g% }+ T5 R6 s5 k" C3 e
end
9 J% }7 R+ w5 u/ x$ Y3 `! @9 n8 L- T& _. m. a ?5 d( a) ^' N
|