请问:
3 T# m5 M; k5 ]% n: _/ o随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?+ w% h$ N5 o' P& X+ N
2 [' a, C8 L2 h9 c5 J! o7 I
1 p2 }7 D, z: C; w" U
turtles-own [ energy ]
/ x# R1 O, {' d$ s8 Q9 I5 U3 ^to setup j1 d+ n( A9 s
clear-all
/ n* e P* [% m4 F8 B* Fset-default-shape turtles "square"
, ^* ~) C" E- ^) E6 a2 Tcrt nutrition1 i S' A# Z5 z+ ?- U
ask turtles[8 t0 k' A9 X$ ?6 G7 E
set color white6 C' r7 o2 l' R$ a
setxy random-pxcor random-pycor]: G( L' G# ]5 g$ u" e. E
9 ~% {2 K7 m. D( |! L+ _6 Mask n-of microbes-initialization patches
% F' q" N- y, X( c3 q; U [ set pcolor green]. V" a3 T# Z) G- }
ask turtles [set energy 1]+ s# Y2 S; m3 ^0 U# G9 k, C; k1 t
end
+ V1 l G2 v) u$ @" _
2 B4 T6 r" f' e& Q7 Xto go
/ R3 l5 s2 }# h ask turtles [set heading 90 * random 4 fd 1]
h% E+ r" M$ I+ O( T4 i ask patches with [ any? turtles-here], g8 K g ~: h) R: N
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]: c. C; z0 O/ B: K
ask turtles [ if energy = 0 [die ]]) b# P. V& h# p( P! x: L. ]4 s
end
7 o6 d; d8 f- s2 ]7 C, D2 J5 t# {% e
to tt
( F7 Y+ T, h' Gask patches [set pcolor gray ]) h5 I; S4 J! }% u
ask turtles [set energy energy - 1]
5 H" a, E) N B+ d% Qend9 c' x: p- t. |3 p5 H# O7 I
' P4 \. F9 K& p L( \% x: x
|