请问:. Q/ t" h0 n, w9 \+ }7 O. k
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?; F1 T8 w u" g9 Q& d) \
4 U1 x) f! s3 b' U. W
. K( g9 w; P' o
turtles-own [ energy ]# y, s7 F) v$ H: P; ]$ b3 d
to setup# n P6 b$ {/ [+ P
clear-all
# B3 D9 m& V6 N0 zset-default-shape turtles "square"; ^ r" P, I: }, H
crt nutrition+ a8 z C4 R1 e, z5 t; Y7 F6 ~) N( d
ask turtles[% H( i" l$ W' p7 {- [# L' } F E
set color white
1 E3 `4 V6 @ T( f' [7 H setxy random-pxcor random-pycor]0 k$ h9 s" [2 O3 {% i7 q
5 h; }8 i! l- b- w7 s; S' [; K2 Y: zask n-of microbes-initialization patches
L( W: }% O9 m" y" f [ set pcolor green]
2 v Q3 r7 u/ v+ P9 { ask turtles [set energy 1]
% B. {. I" P% F% qend
" _* V2 o. H/ h; s) [5 E5 |* q8 L. j
to go8 \: ?5 S& D8 w) d, \4 |& b. `3 B
ask turtles [set heading 90 * random 4 fd 1]
' c/ i9 K8 v: R2 j m2 H ask patches with [ any? turtles-here]
0 F6 \. t, b5 {0 W [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
# p' O1 ^. a' h5 M2 u ask turtles [ if energy = 0 [die ]]
* C, b6 _8 G4 X3 v5 g/ a end# H/ n- W$ V2 m. ~9 L* c
9 a( {8 h, P+ X9 Q0 O, ]( ^5 Fto tt
! F$ D8 e J3 O, f% p! Z2 I' pask patches [set pcolor gray ]: Q. `0 B5 S' G( k+ m
ask turtles [set energy energy - 1]
4 b$ o. @) V/ Bend
7 f m r5 x* c; X$ E5 O U- x$ h4 ]
f8 T+ c, S2 v* C, l3 g, I |