请问:! u2 E9 R" \$ `9 O1 s+ f* ?9 F) z
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?! F/ _ h+ Q4 Q) R3 @. ]. r$ u2 A
: X" g3 a1 m- J) s' U$ ?4 G4 a8 s( c
9 V/ v* w5 F) r1 f4 r
turtles-own [ energy ]
; c r* D( {& Zto setup
5 V N# s0 X% ?9 ~clear-all- B" q7 i, e! v" }
set-default-shape turtles "square"$ Q; s$ H4 x( L* y Y
crt nutrition
' m* n: q4 B; e. }) I) nask turtles[: o5 `0 ` L2 ] s
set color white7 R! t% m# I( H3 K
setxy random-pxcor random-pycor]
9 m) i, N+ D9 N% X. R; H
+ x+ |6 f- U. N4 Bask n-of microbes-initialization patches
% h% n) @+ D' O, C0 m [ set pcolor green]+ r4 D% d( P* _7 `* |, W
ask turtles [set energy 1]0 K/ H" q; e( z; Z/ Y6 S+ h
end! W& R; e6 Y; h5 ~ T* v/ p
; o* K6 j7 V& ]9 e
to go! k3 _$ u* G# b" q9 u
ask turtles [set heading 90 * random 4 fd 1]) r" u& ?- J/ D/ F- y; ]
ask patches with [ any? turtles-here]
( J* z) T" M! C" q* P: L [ if pcolor = green and random 100 < chance-of-congregating [tt ]]3 G$ w8 a( j% S4 ?1 o
ask turtles [ if energy = 0 [die ]]% c) A9 N" {+ M) g1 L
end
+ @& X! L/ L0 D% V+ U
( `4 w1 h/ e* P mto tt
( n# @; E: I+ g1 Vask patches [set pcolor gray ]
0 X' X9 h8 T( S! [* V' J" E- _ask turtles [set energy energy - 1]
- e& Q1 G0 Y9 [% j- B5 a/ Yend" W1 w6 |* z- n# J3 w# z) t
' |7 n, r. I2 D+ l: A; ?0 U
|