请问:
9 ]7 e! j0 x. Q随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ u* R3 A% j, h6 I7 q- e$ E K$ |; f, B
2 ]1 J- Z1 M' i/ r8 \# \; |: r 3 ?: v) u5 N& G9 o) W8 ?8 e! `3 }
turtles-own [ energy ]. o6 T& u S5 {& \( h6 _0 A
to setup+ F0 p8 r2 t" A8 @. o
clear-all7 ^+ ~: V! a3 r; G% j) i# m. r8 G
set-default-shape turtles "square"5 M$ Z7 T# ^+ J$ {
crt nutrition, m: D4 `: J+ y1 i
ask turtles[
- S3 R% `1 o" X Y$ [) y1 ^ set color white
% @7 ~8 ?# G5 z4 T6 ~0 H* M7 M setxy random-pxcor random-pycor]
b5 W* K- N/ k8 a % n. { d' P) |# |" ?9 Q
ask n-of microbes-initialization patches
' x6 I( [7 O0 X( M [ set pcolor green]
, b. a4 v# N7 A/ W; U ask turtles [set energy 1]
. M/ B6 z3 ^# H! f6 ]end. Q9 o9 k1 W! K: y
/ i) u+ H( U/ [$ t& e }to go
) Z; b: _9 `% W9 N ask turtles [set heading 90 * random 4 fd 1]5 _. ~* V6 N" g7 L; X
ask patches with [ any? turtles-here]
5 O G- h) I; E% k1 z8 L [ if pcolor = green and random 100 < chance-of-congregating [tt ]]: ]4 e" J6 S: G! U
ask turtles [ if energy = 0 [die ]]" Y$ U) A( F ^+ V$ }
end$ R$ [& i, G2 b& j/ y; @
f* N, G' H8 N' C& R2 y* \to tt `( b: Y" O# b o# v$ ~
ask patches [set pcolor gray ]
4 _! J' ?6 U- @, S3 xask turtles [set energy energy - 1]
5 ]& O7 V3 t/ ~1 q9 |5 tend
8 g. a7 I, O* x3 k* w% H$ k* e* S) P) E/ \" q- y
|