请问:$ _5 F# T+ K' W8 U, T' a+ J
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?) B9 r4 v: ^5 z
- a. ^5 Z R' U& X, g) ` f
/ k9 f5 l$ |0 R6 V: D* Pturtles-own [ energy ]9 o2 \- b0 c, a5 r, {
to setup4 G; ]$ Z4 P/ p8 i
clear-all; ]& h; G$ [5 I( }) m) `
set-default-shape turtles "square"
' h$ e: y! @+ e7 L9 e) m- Hcrt nutrition
, u$ e' I: r4 M8 _) @( B" ^9 S/ T+ Fask turtles[
' I3 m) \5 X; x4 L4 {7 @; S( h set color white
9 p. H. U: G% E t* j setxy random-pxcor random-pycor]
( v+ V- N& q0 N( h m. C" N1 \ x 4 }& ]4 Q# U8 m1 J( j; L
ask n-of microbes-initialization patches1 P( W3 ^) |6 m* N& u) a
[ set pcolor green]- k5 r# D" R7 x8 g. u! T5 |7 U
ask turtles [set energy 1]$ g C+ y3 v" d
end+ `7 Y( `3 m' C1 S8 \3 w
5 B/ Q8 ~3 \6 X" i0 z9 uto go2 h7 a+ s- n, ?8 w. Y) b/ r
ask turtles [set heading 90 * random 4 fd 1]
. P* u4 l# X7 L2 Z1 F8 O; ^# ?& A0 [ ask patches with [ any? turtles-here]
6 d7 r( M4 V7 p! u8 P1 j5 w$ h ? [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
& @. _8 U N* w+ V x9 y3 Q ask turtles [ if energy = 0 [die ]]
: |' V( g) O l! m5 q( V2 d end
, E; |# B- U0 h& L0 m- T
+ X) O9 q& y3 n5 \to tt
: e5 } E9 t. ?8 w" a) yask patches [set pcolor gray ]
( G$ o) B9 l K. {6 W! \ask turtles [set energy energy - 1]
+ \" t$ y5 c6 C7 S8 kend
) z. t! c7 M& B' |5 }! O, y2 {% {3 H4 S. v6 y5 J
|