请问:
! K! ]! J' _' Y3 A* @随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?( g" G' ~8 E3 U$ h! t
% ]. R3 b; i6 o# ]
) n- a0 M) d) g9 i9 mturtles-own [ energy ]0 K6 e0 S. V* X# ~- d
to setup/ j( }* y* B3 n
clear-all
3 l# S( Y" R' E0 x8 Z" a2 H6 H$ J" Y/ g* Yset-default-shape turtles "square"7 w' _, X# }: v1 C, F
crt nutrition
* Y$ M/ M* e3 B! R$ Zask turtles[
, T& k! Y8 ]- H' s7 l h set color white, R5 V' D# F/ C4 ?6 c
setxy random-pxcor random-pycor]: U4 ?) X' g& _3 A% `, a
7 `+ k* q8 ]/ I5 ]! w; n' X' i0 Sask n-of microbes-initialization patches# a) |1 W* w) W/ t% S
[ set pcolor green]: s7 ]. U! s6 d1 L: A; n0 x
ask turtles [set energy 1]- B2 e+ h1 s6 v0 O. H8 k* P; v: c
end3 B: m2 |( `! L" _" R- H
; K& X3 q6 \8 n9 F* p% I! [/ U
to go6 C1 ` ~( z" Q$ \0 z
ask turtles [set heading 90 * random 4 fd 1]
/ ~. Q. |, S3 f. t# T0 j) \ ask patches with [ any? turtles-here]1 V0 {& g; F0 y6 l$ d
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
9 I% y+ A; F# z9 S9 k1 F/ e6 ^ ask turtles [ if energy = 0 [die ]]
" z) a: Y. v+ } end: M4 ^6 g& I* J
; r- o+ e* c6 q. b8 _$ ~; Bto tt
7 V, S' C4 B0 D& aask patches [set pcolor gray ]5 d$ h, s; O; x4 n) b9 ^9 z3 H
ask turtles [set energy energy - 1]
' R/ C* H+ f9 tend
& g Q: ~8 ]/ E4 P# b% Z: i8 v% [% i
|