请问:
( d: Q! _5 _6 ?- R( W) b$ V随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
6 h: ~6 x2 p5 _: J. e% W- w
- F' M! o: C M4 Z : U8 s) o2 l4 O: o3 E
turtles-own [ energy ]4 p9 j4 H! k, `- Q) S6 `! J! }! j
to setup
* _* C0 S; V3 C4 iclear-all4 s: o7 R3 j' L8 ~8 z
set-default-shape turtles "square"
6 F! E( d3 G4 X! Vcrt nutrition
; j0 v" Y' g( N% K* }7 q+ `ask turtles[" K6 t& x- G) X- e: g' o. K
set color white3 k; z- o: S* u2 F* G, @5 i6 C" S9 D
setxy random-pxcor random-pycor]0 O) m4 D C1 o h/ l( a. x
) n3 L. ]7 [" h/ e4 Kask n-of microbes-initialization patches
& v! S7 y% o5 A2 N# r [ set pcolor green]
, h8 |6 c/ }9 N W9 C ask turtles [set energy 1]% z2 f, j* X- n* h0 r- K
end
+ D' c7 `0 j" C" G& w! D- Q3 S3 b2 q* G1 }, s# H9 `* ~) L( j0 T
to go# z# }+ O; v, f1 i6 f, t
ask turtles [set heading 90 * random 4 fd 1]0 y o" u7 Z1 U J6 c0 v: }
ask patches with [ any? turtles-here]
[, n j- ^8 f% Z7 V6 [9 s$ `7 X% I6 W [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
" _* F4 c% k5 d$ U: d5 `5 z ask turtles [ if energy = 0 [die ]]2 c& h: h8 Y5 J1 W+ F7 i5 X
end
' X5 I* o' U+ D1 s" F; h8 D
8 b3 f$ c: q# N4 d9 E: Cto tt- i7 E# D7 z! w }* L) n# a* `
ask patches [set pcolor gray ]
) A5 ~ i( {2 s& _! z0 o& jask turtles [set energy energy - 1]
# ]( P# o7 v' U( q: ~end! g7 U6 l- S8 s8 S# g
- b/ [8 e# A |, ~8 K0 c& O, Z |