请问:$ P& K4 _' n1 C9 u+ @; H
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
! B3 S2 q) w: o _# q
6 D4 a! A/ l+ B " B3 @0 E1 b/ X1 |0 W
turtles-own [ energy ]
$ N. {9 I+ I9 z' E$ vto setup z/ u4 Y2 v5 h+ C
clear-all
y: `0 F! p( V5 R% ^& i. }set-default-shape turtles "square"' X' ]5 I( D; n- U
crt nutrition
" T! k6 E3 p1 J- E% Nask turtles[
% s, d/ K1 s( X {+ P set color white- G, |2 v3 _' ^. y# S Z) x' @5 B
setxy random-pxcor random-pycor]
& ~& m& O7 i4 H( i, s; Q , s1 u2 y- `7 g$ s; T7 \0 f& p
ask n-of microbes-initialization patches' q2 q; Q, @. ]3 L9 C
[ set pcolor green]& K2 ]# [* M! F
ask turtles [set energy 1]
$ Z7 |' }; j/ y6 S3 p, k. q& G3 Bend9 E$ k- E9 w ~. }- Z
' x% K: h5 s; \4 B) v# ?/ v
to go }) `8 y! d5 i4 M4 G2 @
ask turtles [set heading 90 * random 4 fd 1] W" S& D/ f, }& l# G- ?* F9 t9 o
ask patches with [ any? turtles-here]
: ~- l& R2 A! {9 x& V; | [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
. U% e' q& b% f; o ask turtles [ if energy = 0 [die ]]
5 R2 I: @% A; f: [' N/ a end7 E: ?, |0 S7 u
. s1 W) `5 l7 Zto tt
Q2 Y5 z) ^# a% P. G2 pask patches [set pcolor gray ]! L0 D7 k5 A5 ?) j" i5 K5 C, E! _
ask turtles [set energy energy - 1]( F$ g g& s" X/ F0 Z4 C( H
end
2 d/ M$ T& a5 e# r6 K8 h# F
# x( Z' t* p& m) H |