请问:
4 E3 i% S+ ^& f Z: ~9 r随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
( H6 d( \% f# q2 N( q6 c3 m }; f" r7 L8 F$ |$ X( j
: S" j4 U4 d5 K) a, y) h8 u
turtles-own [ energy ]7 V$ w+ A6 ^: E }7 m p. h3 |
to setup
0 R5 n2 ~0 K% T9 o! Q1 hclear-all
9 {/ G7 K1 w5 Rset-default-shape turtles "square"1 u1 D5 c8 H0 Z- D( Z3 V" n
crt nutrition
2 P4 v- S% ?" Z) @% Wask turtles[% c' W W' d* h) J0 z0 n
set color white# Q) t d7 a1 ?! ]
setxy random-pxcor random-pycor]8 L* f, I* X R) D0 ~& D4 Y
# f4 k4 A/ V* l( _6 U4 C# g# @ask n-of microbes-initialization patches. `6 i6 k( u! B0 X! d y2 u; H6 G+ R
[ set pcolor green]6 m, K; T: G* q. D
ask turtles [set energy 1]. q2 f) f l- e- F8 a
end
# w& f; y7 G( |; e4 r
+ p3 p' g* p! ], z- Nto go8 Y. V* K% b. W v
ask turtles [set heading 90 * random 4 fd 1]. b$ |, a4 Y6 K. [, c4 Y& j
ask patches with [ any? turtles-here]; ~8 v0 f# O) h( `7 b) x
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ ^3 ^5 f- U# t9 n ask turtles [ if energy = 0 [die ]]
( b, P9 y! f& l( M& t end
' T% H5 E5 _1 C1 G. y% h A% I4 H) g2 h; V
to tt/ b; y) D u; _) ^; W- U% A
ask patches [set pcolor gray ]
; C4 O1 U) Z8 r- y0 h; E( j' y( e6 Task turtles [set energy energy - 1]: E8 m: V- B9 K1 {1 P, V* _
end
8 q) J) q3 U1 C; k# I/ S
' Q& n0 h4 W% H" y2 V |