请问:2 B' q$ z6 N) ~, P: |, q/ f
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
' Z6 H4 a U& H4 X8 V0 A& I/ r( Y3 N+ W6 X3 k
3 M/ R) E; d G3 m1 m" q9 Uturtles-own [ energy ]* E6 q1 }+ r9 t) z, M! `7 ?+ \
to setup8 B/ I* O7 \# F
clear-all
" j, i* A) O+ V; ~set-default-shape turtles "square"
* q$ j+ k; B- p, q6 ^$ G8 qcrt nutrition
8 n9 U7 n6 S" { v- t0 \% v' w& lask turtles[4 _, u1 }9 [* p) F* N% Y
set color white
$ V/ q4 y" i: y4 a- w/ G0 z% F, k setxy random-pxcor random-pycor]
$ U8 V/ H. [7 {/ y# y& b, o ) j" l. Q" I' E5 C; F$ A' o/ \( g
ask n-of microbes-initialization patches: V% r1 G$ M2 n P9 C
[ set pcolor green]3 k, N2 P4 y5 B
ask turtles [set energy 1]& B. t/ i2 H% `
end
8 u3 |7 I1 G U6 l E$ |+ x% _( x9 x9 S. ~4 U( y4 O8 {
to go
( }, j, i$ h2 p! z ask turtles [set heading 90 * random 4 fd 1]
& C$ p6 Y* `) f. X ask patches with [ any? turtles-here]
: `4 b& e. X/ x7 @: `# t9 A: `8 o& @ [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
* t. d9 {; W2 ?! P ask turtles [ if energy = 0 [die ]]
8 L8 l9 A5 V2 j end$ |, {! x( i7 N- {5 l
- e/ s0 {. n2 K
to tt
2 P& e& }% D+ M$ D! Pask patches [set pcolor gray ]
2 q9 {4 N+ J- W7 {ask turtles [set energy energy - 1]7 j( E3 [% q) m. N: z# p* _
end9 ?9 N4 ]" k/ [$ a7 V
/ K" n2 U# c9 {0 o, D0 Q3 i |