请问:! a% g7 c9 \0 [7 d8 S1 N
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
: e1 c" P8 \4 L: S: B. F9 ?4 o1 A! `, A* G( i$ I% h/ u
+ J- c1 q2 k5 v) L4 C! Z
turtles-own [ energy ]5 U/ H9 L/ m7 B$ {
to setup$ p' A, V6 A0 ~/ q2 N
clear-all' t$ y. p+ b) l% F
set-default-shape turtles "square"; I' a2 ^7 S/ X1 P- D! V Z& G
crt nutrition5 P* v- y$ E6 }$ g; B
ask turtles[! l U3 i9 Y! u3 u j6 r$ t
set color white0 o9 z' J! \. g9 s
setxy random-pxcor random-pycor]7 p( ]" Y# x B6 \! w: n
8 B. h3 ]4 W" D2 U
ask n-of microbes-initialization patches; k# y) J9 a6 G' L
[ set pcolor green]
/ I6 I) }" J& }' v* l ask turtles [set energy 1]
; ~- P0 ~0 D6 v x" J7 |# K# T/ b# fend4 {- Y' b( ^- F( P% r
' u; q+ t# H, g
to go/ |# V5 Q; |+ k/ m4 d/ \8 Y
ask turtles [set heading 90 * random 4 fd 1]" m3 D0 J2 [) b0 B7 u1 @3 G7 f$ Y& T
ask patches with [ any? turtles-here]
+ m) X4 A' f' f' ^8 y$ d [ if pcolor = green and random 100 < chance-of-congregating [tt ]]2 e3 D+ Q" Q: t! P3 J5 H! f
ask turtles [ if energy = 0 [die ]]1 F0 P2 |# j1 \2 D( E5 T6 v
end, m, \6 d# l9 B* J. r: c, w
3 s, T8 |3 n G! c& rto tt9 M2 m# H, P V/ {, `
ask patches [set pcolor gray ]1 e( O" @0 j0 n |6 N E8 |
ask turtles [set energy energy - 1]5 h% J& G2 P, T" W; d6 V+ g- o$ J0 B
end
8 o6 I' R* ^7 [! ^! s9 b
& U/ |' {1 R# J- c |