请问:. x ]4 A8 j2 m6 G" b
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?2 B2 x, U4 W( Z' q
( A( l: j, }4 a" ]: H
" j5 L6 q0 h6 W: Zturtles-own [ energy ]3 n" n* M, Q- K! c7 c* F
to setup
$ A F+ p, ^2 I0 ]4 J. ^% H7 Rclear-all) p# q& j9 ]2 G5 Q
set-default-shape turtles "square") _0 [- h: t( Y* R
crt nutrition
9 Y7 u1 Q1 \- k5 aask turtles[6 M0 K/ z9 A. n# n# k; p6 n
set color white# ]' }+ \ D; u5 ]" l [( H) Y( Y
setxy random-pxcor random-pycor]
, Q7 f2 [; F, v. f! A# g 8 e! u$ m' r! ~5 H/ \
ask n-of microbes-initialization patches% b2 O4 w! O! \
[ set pcolor green]) R$ d, f3 S5 x. Y+ j
ask turtles [set energy 1]
6 i3 o% @: ?' R' c# [. Eend' i5 u! _' F: B V8 v3 j
c) Q& z* Y# F7 C) i
to go( k: {. P, J, U8 m' I* u# \
ask turtles [set heading 90 * random 4 fd 1]
$ D; `$ X# |3 H6 ` ask patches with [ any? turtles-here]& b* B8 P8 e3 B, S7 Q8 a$ _' {5 D4 X0 d
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
+ B2 y3 l1 |; D; G' I. ` ask turtles [ if energy = 0 [die ]]
0 a# ]+ g$ \* U& R L end& r* a( a* B1 k9 W! V, o# b
9 V. y- K* D1 \- | {
to tt! g% |; B. w5 [% Q
ask patches [set pcolor gray ]( c3 t w2 x' `
ask turtles [set energy energy - 1]
M. [+ Z: K3 }- F Lend+ P* Y ~4 x' h% A% [7 _% M9 r+ P" A
8 Q- [1 H( L2 q7 v
|