请问:% G2 N0 y t# ^& h
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?' W4 s z; L, T/ o b2 ?
: x R7 c4 t; y0 y# I
7 v/ p& V2 W) f* Uturtles-own [ energy ]
* Z, k3 ^5 f0 Eto setup
9 W! Z# ^! a- Q9 L: Rclear-all
3 x4 I& A+ o! d9 sset-default-shape turtles "square"% ]! H% s5 h, l! b
crt nutrition D' K+ X$ u3 \( ]
ask turtles[; |$ o9 X! x. c. f: D: _
set color white G' L/ p7 D' R3 c. c
setxy random-pxcor random-pycor]8 o# X: z* ~ B: d, j& L( E3 b
) m- q5 U* a" J* B( ]ask n-of microbes-initialization patches7 g* l/ G- q1 i5 O+ w) u
[ set pcolor green]9 X1 w3 N* X# f
ask turtles [set energy 1]
+ n* Q" c' C% I. n' ?end- w' w1 ~ l" J9 Y* s: N
) x* Z' N, u8 n+ z' f
to go: a, `: f* j* E! d( A' o5 H$ s+ C% M
ask turtles [set heading 90 * random 4 fd 1]4 i2 C# q9 r: z) y' m
ask patches with [ any? turtles-here]
, g6 |) H4 | _3 h [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
8 n5 K( j* k ]/ W e$ D. C ask turtles [ if energy = 0 [die ]]/ S- c" n0 U* O0 e1 |+ j
end
6 S+ e3 b: D; E' n0 K$ O9 J5 C; p; `& L: q
to tt
6 f$ H3 z$ g$ B5 I. y) l9 I0 q" x' ^2 hask patches [set pcolor gray ]$ c. G$ [5 f% W: r( C) O
ask turtles [set energy energy - 1]
# k0 R. G( M9 ^: qend6 U9 V ~7 \- q" Y
" V. f3 V% `2 _ |