请问:
) x0 `0 }, Q* d+ H3 a9 ^随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?7 q0 S% G' \9 P N) J* z) n, C, I
* B$ Z7 @* {, M( T' h X2 B
% O) W3 f+ o. m' m
turtles-own [ energy ]/ p4 f1 b# Q, K& j( t% G9 H5 m }
to setup
# z! S0 c9 g' |+ ]3 Hclear-all
8 o, Y7 f5 A1 B' i; ~set-default-shape turtles "square"0 E. J- i z' a: C. U$ Z6 h7 ^& z
crt nutrition
. o$ V8 [/ Z W, I8 T( \ask turtles[
! W* ]6 l$ Y9 C' t% s+ |/ I6 H set color white6 M, u; v7 ^5 I9 n0 V- y- ^* k
setxy random-pxcor random-pycor]5 F# N G0 j8 u9 D) u# [: W
! z" f) R1 x" ^8 hask n-of microbes-initialization patches
1 u: M p9 u& d7 Q1 ?0 H6 A/ b3 j [ set pcolor green]
4 L! `9 q( c. n6 x) V2 ~2 x ask turtles [set energy 1]+ ^3 U3 X' |* N, |& y
end
7 N- S* j' F, h
6 U% D9 Y S/ e; R% |( ]to go" H# U6 Q8 d( \2 J+ l
ask turtles [set heading 90 * random 4 fd 1]; K& N4 Y5 b9 ~1 u% x1 m3 _
ask patches with [ any? turtles-here]
7 L* w$ b* ^3 }, B [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
0 _ R6 q9 E( P# ]. G0 `7 D ask turtles [ if energy = 0 [die ]]# _9 ^9 e( b n
end
3 b4 P, q! p8 P" b. I9 E
; X. s* c- Z6 h {, B! h+ Eto tt
7 y; F" b/ |4 E( {+ e, s; d0 | k3 jask patches [set pcolor gray ]3 J G9 C; z6 A! L
ask turtles [set energy energy - 1]. w5 ^3 E' P: ~* F& N# H
end" C3 w0 p7 n$ }6 H
1 l1 z: g, F7 R, _# B
|