请问:8 b6 l! _% [* ^
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
' w- t( x- k6 X: q" e9 t6 w
9 @+ [/ o* ], N+ q4 R / B% q7 o3 F$ R& I% W" @. x
turtles-own [ energy ]
* |3 t5 _& B4 D$ I0 d5 l# |to setup
: v4 k- L u4 T* k# e2 Fclear-all
* H8 b) o/ s8 ]6 W% T# ~5 pset-default-shape turtles "square"/ h% C9 K& {6 W7 D
crt nutrition$ A4 F% d4 a+ ~1 h
ask turtles[
3 b+ I# r4 h9 ^/ Q( Z+ g4 Z2 a, P set color white
\- R6 b$ r5 S! @ setxy random-pxcor random-pycor]9 J7 c) x' R8 i. l: ^$ n' }" a0 B# t
: |# [" f9 n; E, w
ask n-of microbes-initialization patches b: ]" ^) b1 L7 U
[ set pcolor green]$ X) p4 g! F. O3 }, a5 ^
ask turtles [set energy 1]' y' k3 _4 B: p) x; T' a
end
- N& o) }7 F$ O1 k$ y# |/ D2 p. ^3 X; @8 g, v& U
to go
B3 v" Y% r( I% Q ask turtles [set heading 90 * random 4 fd 1]9 c& n1 B& N- u3 l2 y0 Y; `
ask patches with [ any? turtles-here]
1 X- o2 H6 f9 X" _0 }( N$ x. i [ if pcolor = green and random 100 < chance-of-congregating [tt ]]4 H5 i" t- M6 C6 K* [ V& [6 V/ |( d
ask turtles [ if energy = 0 [die ]]
( |3 O8 P6 [% D end
7 k! ^" ?; y! W! M/ T0 y* |# h6 I4 W @# X; o, ~/ P% g
to tt
* e( G8 ^/ B, J$ @ask patches [set pcolor gray ]
' k0 Z7 f- Y: v/ Lask turtles [set energy energy - 1]
4 W+ N( O0 y. a3 X7 Vend
* R! q0 f" J1 |8 @" A( V. |
6 m! n2 r- @& I |