请问:
, O& s2 Q6 W$ Z* |- N3 c随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
8 `) V% N6 ~# `$ c. }- U2 y8 M& }. I v' ~9 c
' v( {+ v0 p# f& @5 Hturtles-own [ energy ]( h( B/ B0 g( o( }& A
to setup t# I% L+ [. F
clear-all7 B) f4 T L& O; y; w6 g! l
set-default-shape turtles "square"% y* ~# \ b" C7 g* _) n: V
crt nutrition
+ |- g. f+ t J: B8 W2 U* qask turtles[
4 }- [% X& T8 A1 D1 Y: a5 J set color white) L1 J" d. K% M' I; V- P3 i6 t' Y
setxy random-pxcor random-pycor]
0 M4 `- o. h' N: I
8 w; d! b% P; s4 x, d5 O) bask n-of microbes-initialization patches
1 M( V- [. F/ r4 I [ set pcolor green], k% E8 F ?; f. i8 L
ask turtles [set energy 1]
: H# D$ S$ y0 @9 m2 ~ N+ |1 gend7 u9 }; s8 {7 P+ R! Q% h9 V
' _6 F, s, ?( m1 Z( j- w# m9 }
to go
/ x9 \' q9 J$ B3 m( N ask turtles [set heading 90 * random 4 fd 1]
8 y% r; R) `) ?' m6 r ask patches with [ any? turtles-here]1 E( s/ }: ?' ?, b
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
; N( N. q ` w2 t; G. U- R6 I ask turtles [ if energy = 0 [die ]]% i- m; I0 Z M
end
7 X$ Q7 `4 Q8 z( O3 D; m
4 E6 T; T8 V5 Z/ I, ]to tt
' u/ l: R- C9 }& j( w1 hask patches [set pcolor gray ]
$ H0 W; x; U( X# G% L% k: g& C; y N/ \ask turtles [set energy energy - 1]
6 I2 S q3 n# }, z1 Xend& l0 i' k+ C) R7 j/ G. a" K
5 g1 f7 @8 e' }( x' o. g
|