请问:% A8 U( P5 V I5 e' H- r
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
) r5 W4 t6 @6 c% Z6 d" D3 x6 H2 `3 q2 P8 Z7 L0 |+ r
7 c9 c7 Z5 S: s- E; h5 Zturtles-own [ energy ]5 V E. r' \7 q: X, C/ C
to setup
4 U$ L: p( E( B( U* \( t a& \clear-all( Z% @: n) M; \7 U4 }& s
set-default-shape turtles "square"
7 q. m% g5 O8 y* }crt nutrition& P2 p+ [4 F: t$ v" h
ask turtles[
3 Z, u; K) l. ?+ C1 r8 ^0 {) y set color white1 @: w& z7 _3 T0 L! `0 J3 @& e
setxy random-pxcor random-pycor]
}+ d2 p H& e
8 N: J" {. K# z a {ask n-of microbes-initialization patches" P$ a; R, o3 n, B! j
[ set pcolor green]
2 C9 y, E% |3 Y ask turtles [set energy 1]2 X: i& s, S1 G) ~0 I
end
. M) R. l6 ~( @3 m! }" h! V Y& z
; k8 [5 B7 _$ N0 X6 U# D9 \- Oto go
. q& Y( z3 E( Q% S8 ], \) h/ m ask turtles [set heading 90 * random 4 fd 1]
+ K/ n/ y5 U) W$ ]% X( e; M0 x7 X ask patches with [ any? turtles-here]) ^$ @0 [6 ^2 b( J! P
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]/ ?( _! p7 }9 q' @3 L) V
ask turtles [ if energy = 0 [die ]]& ]5 D6 [2 P" R: d6 [! m; y
end
- b( n: R" |5 E8 x/ k1 U0 O" K! m) O
7 c0 N A" a" O6 U2 I) R4 o6 Sto tt2 c" O! m$ P/ t
ask patches [set pcolor gray ]
; Z$ m' A7 ~( Fask turtles [set energy energy - 1]
. X' u7 A, q* @- Aend
) T, P4 y- z0 V0 @
& i* y+ k4 I) B, M |