请问:# [! h& J; Y/ q% n0 r
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
# l8 `+ O) z' \/ E4 X: r' ^* f- j% \. Z& ]
; x3 Y. r5 i2 X/ \8 |; p% vturtles-own [ energy ]! A& K- m# F" ?3 o. j: V5 t. D
to setup
3 ^& }0 ^. b h+ t O, Nclear-all
4 o& Z' ?& f; V# eset-default-shape turtles "square"
6 m% u' x5 f5 L2 P1 Bcrt nutrition5 o9 Q% V7 ^1 e6 n) J. E6 ~2 ~" k3 e
ask turtles[
. A( S' B0 v) f- t2 f set color white$ I- ~% A$ j: X4 j1 t) l; J. V0 e
setxy random-pxcor random-pycor]
. y/ U0 T# f- } 7 W3 w) D$ [; n
ask n-of microbes-initialization patches
6 ^$ Z" u$ C" `6 Z" r9 f [ set pcolor green]
Y8 U% z! T: J8 y ask turtles [set energy 1]9 I7 {6 y; @) ~
end7 D+ _6 I, e0 M2 H3 q
; b4 D. E5 f) x) c% L2 k( m8 X Vto go
0 B) B/ s- P; ~! `% } ask turtles [set heading 90 * random 4 fd 1]0 m' \, c# Y& } ^
ask patches with [ any? turtles-here]
* a* t% g+ w! H1 t) H [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ Y+ T2 D7 h2 E( s& V6 d1 c ask turtles [ if energy = 0 [die ]]3 U3 P9 S0 q/ L
end
: w/ P0 g7 \* t" \: e, J& [) `( c
to tt
% Z. v2 y0 P6 Z( b q; e4 Q8 _% ^# Y: Cask patches [set pcolor gray ]
$ k$ }3 p$ [1 T; Vask turtles [set energy energy - 1]
8 Y- K$ f9 j* e( n- oend
0 j; U; ]& }$ Z3 u$ l8 C% f/ A5 ~; L
|