请问:& X0 m, d/ F1 s- u. D6 Y2 H
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?5 s1 e2 a9 ] |) R+ X: @, u1 p
& R, i2 i1 t4 [
5 t- b! o: C1 w1 j
turtles-own [ energy ]
2 J; {" d7 S# ]- ]5 B# _to setup
' @' S, X8 i+ Oclear-all
! U( G1 p% P; ^' zset-default-shape turtles "square"8 d. Y9 h+ a" a0 Z8 O6 N
crt nutrition [: V z' e7 ~5 g& I3 a- g) N
ask turtles[
8 L( S/ q. A u+ ~% ` r set color white
3 B# `& `6 z* l- ~& z; U1 ] setxy random-pxcor random-pycor]; b; N" w% m* W7 K, x8 D0 ~9 O
5 M9 J) h1 E% E8 o6 l* }9 p+ task n-of microbes-initialization patches
) s, b, o6 `* b4 { [ set pcolor green]
! O$ F5 c8 B1 i ask turtles [set energy 1]
. |! k M+ p6 m+ @end) C" b- S# x) h$ t" a4 C
, ~, k, W( d. c
to go
1 |4 h4 t4 a# u" N$ U+ y4 w7 P ask turtles [set heading 90 * random 4 fd 1]8 o' p* n1 M2 m: j1 W
ask patches with [ any? turtles-here]
6 p l5 Y8 T8 B7 E$ T3 d r. V( s [ if pcolor = green and random 100 < chance-of-congregating [tt ]]# L2 \' g2 o# S. e/ S; }6 K+ y
ask turtles [ if energy = 0 [die ]]* \2 k% w6 h& V) E# v4 B
end' n% y. {! d, ~/ _3 ]
) k+ e. x4 p& C" O$ c5 r9 H
to tt- O1 `% g: `, Z5 T4 u
ask patches [set pcolor gray ]8 M3 c: X8 Y1 K; ?) c3 ?
ask turtles [set energy energy - 1]! l8 u6 V( \: w& x, b
end* c# U* c% R6 w- |; g4 A
, |9 O/ b. Y; b6 k1 D
|