请问:( H0 h5 U7 K5 @4 T+ E
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
9 o' a( U$ B( u7 [. ^& R7 J. {8 n ~/ x# y% U
' m9 C) M( _4 v- N3 pturtles-own [ energy ]
* g2 m; V" N0 rto setup
3 G* T9 L; X5 c0 V! r3 \clear-all9 d( W+ S( C- m- r; x4 @2 ?
set-default-shape turtles "square"5 m, t4 D1 ?, N+ Z6 x5 ~
crt nutrition+ m; h9 B* A1 x4 _+ O( H; \8 F
ask turtles[
$ H; @3 j; [! M0 B set color white* [) r* V& G. G& U! ` d1 E
setxy random-pxcor random-pycor]1 ]& G) W' u4 G! U3 x
( x/ J/ }! ~9 m& l
ask n-of microbes-initialization patches
* P1 @0 F! X/ M4 N# U4 p [ set pcolor green]
6 A. q( b$ G" D R: X* k. Q, a: k ask turtles [set energy 1]+ l, V! M- E: K* M
end- n5 H8 c$ M- }: a; i
( ^- I6 j0 L6 j a
to go
% `3 }$ z$ F5 S' V& ~6 \9 @0 P ask turtles [set heading 90 * random 4 fd 1]
- u4 O2 B+ W, i% T$ W+ g ask patches with [ any? turtles-here]
! Z# u6 ^) T U# y3 t, P& T7 V [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
( m, j$ F" D9 c& ` ask turtles [ if energy = 0 [die ]]
1 c6 x6 n/ L/ a$ V5 k2 g0 ? end
+ Z! y( Z6 V- _5 f) r
, U7 S( W6 V# {+ P% P) J, f' Kto tt. Q4 {4 D: Z0 j, O
ask patches [set pcolor gray ]$ ?" i G T: ]- q; v9 t
ask turtles [set energy energy - 1]
- H/ M# c3 ~4 Yend
; D5 m/ \$ I; |' s# u* y8 s" P+ c
|