请问:
. U2 i4 [5 H# y0 ?随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 N* W& M' I+ {4 D+ t) v7 s/ k; ]9 F9 [
; F' f4 b. J3 z: |5 h4 Y& Cturtles-own [ energy ] \; v: Z( L9 r3 w
to setup
+ }$ r7 q8 k) Kclear-all
Z! Q! F/ Y1 @set-default-shape turtles "square"
9 X$ {9 Q; D* h: rcrt nutrition! ]0 o2 _* I, W7 L& w/ {
ask turtles[
% R8 M q1 j6 D* N' m set color white! v: n8 l! Z$ x1 S4 {! b
setxy random-pxcor random-pycor]
& q' w" o, b0 N. X1 G( h ) N# N+ W R6 A; h: A* h' ^0 X
ask n-of microbes-initialization patches
5 J! f: n7 s$ D Y& W8 g [ set pcolor green]' K' J0 \2 |2 {: G* S
ask turtles [set energy 1]
9 a4 `! j/ r) g8 z" k8 t Z$ fend8 U8 \! J+ j0 R/ c
/ ?, o* }# s6 p. t) S& ]
to go4 O" s) O! B3 u; ~0 A4 \
ask turtles [set heading 90 * random 4 fd 1]
( D& R& x5 C. u4 K9 o5 N. ]8 S* o ask patches with [ any? turtles-here]
3 j$ {' U2 n* }' d0 F4 m3 j9 a [ if pcolor = green and random 100 < chance-of-congregating [tt ]]/ L5 r8 {3 b7 r
ask turtles [ if energy = 0 [die ]]
: H9 a$ {0 r# H5 x end
+ S- X5 Z0 f4 V; ^1 e7 U" ?8 L* _: o* o3 {
to tt
) ?/ B& _- A8 [% N& hask patches [set pcolor gray ]
; I% {+ ^$ r* m+ |0 yask turtles [set energy energy - 1]
8 o2 ]& D# L, h# h/ g' @. iend1 A0 Y# b0 s( C1 I, }& y: t q
( f6 E3 M, J2 X! M8 J
|