请问:0 P' ?, M0 T5 H. `
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
. I" \7 j) R" f* ?1 |' F$ ^
$ K- Y& n) G+ y' D x9 e. j ! J$ `; |/ y- N
turtles-own [ energy ]
7 S5 y; x' _1 C, @! zto setup
/ H. s9 d1 K1 D7 e8 Hclear-all1 \" I6 |: w. r8 u. P% i
set-default-shape turtles "square"
6 s' a! u; T4 Y" q Ncrt nutrition3 D3 a, }# C" z: \
ask turtles[
4 z9 m' |3 @: U+ D' f set color white
" \9 `9 R6 J- H; g' ]' S setxy random-pxcor random-pycor]
/ U: R' X3 E, B; \
6 Y# U, D. Y" F* ^6 G7 G2 ~. L' gask n-of microbes-initialization patches' p! e. ?- d% G! y% e( l
[ set pcolor green]
3 q4 r2 _8 `+ h5 ? ask turtles [set energy 1]3 Y5 a' ^: T3 z V! k' S
end
( k( F3 |+ R z! r1 D3 J1 H" Z0 W/ `
to go3 i2 j" ?' [' j, o
ask turtles [set heading 90 * random 4 fd 1]1 S# D g1 Y/ V! G- n& Y1 \" k$ \
ask patches with [ any? turtles-here]
7 i0 J( Q% b! B4 |: _. p% K [ if pcolor = green and random 100 < chance-of-congregating [tt ]]6 L1 s3 I, Y. u5 T" [: C/ I0 m' L6 `% {' F
ask turtles [ if energy = 0 [die ]]
/ _8 Z/ Y- p! W end6 v: o7 p, d& P: t' u
7 z5 p# n& x6 Q7 v+ `( f# M* Yto tt( d0 O" @; ^- f2 `( l) d: r: o
ask patches [set pcolor gray ]
, s/ L# ^) A, i. g- T2 ?ask turtles [set energy energy - 1]( W; G) S: u3 |
end# W1 f5 B" M! o% z8 c* n
# X' z. O/ z) s9 S, T |