请问:
! P: Y* z2 \* a" `7 ^随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
; }/ g7 z+ ]/ a5 J' P# K+ c3 d# A: I2 F! Z5 j
& C4 w* \' u% N" M1 m u
turtles-own [ energy ]3 {2 c% E. M7 j) a3 b1 y; c# l
to setup$ Q1 d* q4 i; { U L
clear-all U% J; `5 b/ e" o1 Q% v/ o
set-default-shape turtles "square"- P# N5 |% J7 `. M
crt nutrition, \8 n9 M* O0 _ U
ask turtles[
* V& ?' k. q+ t$ c4 } set color white) u9 g: O* x. Q: a' ^
setxy random-pxcor random-pycor]
6 ~# Z* O# ?& m $ G2 L5 A4 [: ]7 l& D4 R
ask n-of microbes-initialization patches
2 b' \* D7 S5 l: A [ set pcolor green]) f' ]. g. M, j- V7 B3 M" t) l
ask turtles [set energy 1]8 [+ L3 y/ S7 |, U" W' B7 S
end- J7 V4 W; p3 n
( {9 q5 B3 C h; H _% U5 C* sto go1 d0 M8 T5 h3 C! L2 a
ask turtles [set heading 90 * random 4 fd 1]
8 Q, H* F; T( X2 P ask patches with [ any? turtles-here] W+ m) R$ Y1 Q0 }+ g0 V
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
7 {3 O9 U5 W0 I ask turtles [ if energy = 0 [die ]]' _7 Y H t* D( M2 S( I
end
5 n' s/ v* P; C7 r# v, z
$ W! N b' r7 q* U5 l, `( I. zto tt
% Q$ ]5 X3 {2 ]6 w. U. k- M5 Xask patches [set pcolor gray ]" M+ `9 ]" r4 s+ J- w
ask turtles [set energy energy - 1]
3 i( x* Z* C3 D4 ]5 K& F$ Qend% g4 h0 Z; x7 ]% O0 ~) _- k% z
+ G+ F$ n& k9 E" X: G
|