请问:6 a2 } T" K% n' c5 [* i
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?1 Q* m% ?& z' J
' F' h' c- Q5 \ @ ' f" S+ y% p, P4 ~$ i. Z2 q
turtles-own [ energy ]
) M8 ]; |0 s8 l: Zto setup
; t4 C- F! [% O, a- ]clear-all
# g J* A6 _1 h2 w/ kset-default-shape turtles "square"
- P3 Y+ B7 s) A8 Ycrt nutrition
5 E# Q4 d+ T4 z6 X# vask turtles[
, `2 g' c% H9 h5 G( a! U9 a: j set color white6 D6 Q, D0 |9 x: N% q
setxy random-pxcor random-pycor]
: ?! F; M: V7 z% o# T. {, l( p$ I 5 {" ^3 \9 d6 _$ R/ A2 O% p
ask n-of microbes-initialization patches
' c# f" K5 S3 Y: _ [ set pcolor green]8 F5 h1 q( \0 q: Y+ q& ?
ask turtles [set energy 1]% ]+ Z! H% e. N3 x1 X% n; [5 P
end
& s1 u1 ?) Y) L4 y5 ]4 \6 V' l8 H* p6 e x9 p& j+ f* ^: c
to go
& O7 W3 }7 L0 I! j4 J1 c$ t0 k ask turtles [set heading 90 * random 4 fd 1]
. O" ^/ j1 F. w/ m ask patches with [ any? turtles-here]
8 w2 n3 J/ i" A( B [ if pcolor = green and random 100 < chance-of-congregating [tt ]]1 s2 q$ e' d8 Y6 u- o8 L+ ?
ask turtles [ if energy = 0 [die ]]
: V( B8 G: T, S5 Z9 H- p r$ z end
) @1 c7 B% ~ ]9 H( C( x
/ T1 y" T+ Q+ Y2 \; \* Kto tt
0 N: v2 Q2 u8 g! j/ z7 [, H, Pask patches [set pcolor gray ]
" B- C- d1 i, Task turtles [set energy energy - 1]
2 t5 U4 }+ h0 R1 y- mend
4 C/ \# S" r2 i* O6 b1 C. F
' x5 Z" [! u& ]* v1 @$ s |