请问:# ^- C9 N2 I; B% Q
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?. |6 Z# @9 L( m, G: R" y7 _
. Y- F$ A% B1 |# @5 M }) I / O9 M4 X/ z% G E }
turtles-own [ energy ]" C4 Q) y a( B3 o) _
to setup
$ O9 p- \( z5 l5 Qclear-all
/ F4 X' T2 q. G% j aset-default-shape turtles "square"2 P5 V$ X: u* A, E+ ]
crt nutrition1 q( K# y3 q q; V
ask turtles[
- o1 C5 N3 u: j set color white5 ]4 N3 V% R) _! ?/ _& G0 P
setxy random-pxcor random-pycor]; U% e, e2 n& T; V
, r! ^( K+ C2 w: Y0 A4 @' Xask n-of microbes-initialization patches: T/ d2 [! A7 `$ G) L; f% i
[ set pcolor green]4 v8 h* E! O) C: A
ask turtles [set energy 1]- ]+ V4 g* b/ {% ?$ R$ ^
end
. C3 H# x2 ~1 V; }! V& L# t. ?1 x. L s& Y1 \6 h
to go& ^- H2 D: D8 k: Q( j1 W
ask turtles [set heading 90 * random 4 fd 1]
+ N' i8 G" e* \4 J/ Z; z; z2 S; B ask patches with [ any? turtles-here]; Y0 B0 X+ V; w# t1 C+ o
[ if pcolor = green and random 100 < chance-of-congregating [tt ]] s U; }7 E+ P6 Q
ask turtles [ if energy = 0 [die ]]
; Y+ d& O$ L5 z$ y- I end, ?+ V" e2 J7 I0 {9 s9 f$ ~ b
8 I# [% o. F7 c3 w- Bto tt
( C: Q1 |3 i) {% d, B3 n6 Cask patches [set pcolor gray ]. d6 v6 t/ l3 z4 y( x/ ]2 M+ s
ask turtles [set energy energy - 1]+ R4 U8 k1 i& f( M2 G
end
0 n2 h5 x. c4 |" q6 @+ g
/ O4 n$ j9 [0 U; k4 { |