请问:- }) E# p6 c, T; A# {4 x4 n4 Y# i
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?$ W9 T5 R5 g7 R- e' d |$ z; z
8 H& \1 ]9 Z7 X
+ T% x3 r. C/ h Zturtles-own [ energy ]
u; @0 e" N' k* d8 ?. oto setup
' i' i. i1 t9 T! S- {& p. S0 b& k& xclear-all: W Y7 W' n v( g0 i9 z6 ` F. @
set-default-shape turtles "square"/ {9 ?5 ~8 A& P) {- \
crt nutrition
: O, S9 g" H8 Hask turtles[$ d2 r' x9 l) k( c3 c. l' C
set color white5 W/ _$ a: Q) n+ V
setxy random-pxcor random-pycor]3 I; |, p5 Q" |& H) f8 w7 E
! P' B' y4 s; z G. P; O5 G o$ r
ask n-of microbes-initialization patches
2 b+ v! P) a3 y& K [ set pcolor green]& Q r- t. c' ^
ask turtles [set energy 1]. F( Q/ Z4 j# G& ^
end( Y+ O/ O2 f$ X, e
7 H: \6 d9 H: ~; S1 C
to go( W8 F; G; G+ T; s! O
ask turtles [set heading 90 * random 4 fd 1]
. r) D# C: ?" J8 T ask patches with [ any? turtles-here]
+ t8 Z' Y; E7 B9 f1 f [ if pcolor = green and random 100 < chance-of-congregating [tt ]]# W" m& F% w: m
ask turtles [ if energy = 0 [die ]]
8 v" `1 h9 e: d& \3 X3 l end+ U4 i% r6 H! q- p' _: [9 D
& Y5 l% ^, [" t) Q8 _" N5 ?- l4 q
to tt
/ H W# G2 T1 n2 xask patches [set pcolor gray ]
, H; o4 H& E6 q6 J4 vask turtles [set energy energy - 1]% g$ S! k) i' }
end
0 j" L; A0 J a! V" J7 ?
7 H- ^0 i2 R# i0 e |