请问:3 `2 e! H, Y7 w/ U" w
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?/ ~# y1 R) G4 x( P
% [1 Z, Z: J2 C' r, A, M4 X3 Q
" X1 B3 I1 E$ i4 H+ [turtles-own [ energy ]% @7 j' r( k; P2 h7 h2 z. l
to setup
# G: @& f" ?! n I2 Eclear-all0 z# M- P, w! f1 ^
set-default-shape turtles "square"" e& L% K& R' p8 Y! T3 g. n) k
crt nutrition9 \2 P- @7 N7 D' M- R
ask turtles[
* d8 {, D Q, r8 U+ B set color white
- b! }& q( p8 i) o1 `2 e+ ^( i setxy random-pxcor random-pycor]0 E I [1 F! Z. f9 ]
) }% `7 @$ F4 T. `ask n-of microbes-initialization patches* |; E. a/ H) p, Q1 O- G4 u
[ set pcolor green], u$ R! S1 P3 ]3 r& \! z# Z
ask turtles [set energy 1] |, V) X' W' @* u
end
+ m+ x% O! ^) }" ^& a) l$ p9 _+ ]7 ~ s# E
to go, E5 n3 }: Q8 r i
ask turtles [set heading 90 * random 4 fd 1]
4 C% H6 B; q* r( U- b ask patches with [ any? turtles-here]
: J0 a; g4 d# e [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
' j$ I1 D6 {' W& c, E3 _+ j1 g ask turtles [ if energy = 0 [die ]]4 r- U: R' a$ I5 [' Z
end
7 R2 K x# O* F" |( W2 M
* \% m7 H" u. @* ? Dto tt8 u$ j& x5 j- J$ ^* m8 d
ask patches [set pcolor gray ]
! ~ I5 K+ G6 b! e" Cask turtles [set energy energy - 1]
2 K6 w1 |8 U6 `" E2 x' m7 i6 n5 kend. E1 N B4 T+ j" C* Q; U6 n
" Z! f1 ]4 {4 m. e+ o7 K, _- W |