请问:& o& M9 i; g0 x9 i. h( {
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?7 C: |8 [" K8 t4 ~0 T2 [$ G% p
$ J$ I& r* {" x& I: R5 o
% ?0 A5 T; \: \5 [ b/ h4 G% n, \turtles-own [ energy ]
& `& o) @! j* Mto setup7 n* a; H: k1 f. ?* D: `% y
clear-all
) j; R# j3 l3 R7 B" }* Gset-default-shape turtles "square"$ H- |. t$ @. K& a1 Z c
crt nutrition
# {; |: F' U' h- Y8 n* Xask turtles[9 y- E4 W; A! {! [
set color white
8 Z! [) h( N) X2 R( g/ B" j setxy random-pxcor random-pycor]
7 i" P* G8 m2 Y. K3 p/ u 8 I# F* X, G% L$ i# c& h9 m
ask n-of microbes-initialization patches$ S& x; b: s$ N* T6 }! _
[ set pcolor green]4 o- x: X. i( ?+ T2 ?/ j& f ^. c
ask turtles [set energy 1]
4 h& A4 G1 l9 Q! t, C+ cend
' z3 H- U3 E6 v: N* m8 H3 w2 z: z% ]/ h+ m
to go! @5 b# L: y: b* O
ask turtles [set heading 90 * random 4 fd 1]* g& j* _) A) O v, y9 _5 h
ask patches with [ any? turtles-here]7 O; \' A: B' F3 b$ X: k
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]7 F& p* P) \6 J/ M
ask turtles [ if energy = 0 [die ]] H- Z7 V: \; k/ z& W: c% B* x8 ?' N
end
) f. K; |$ e6 @
. k2 [6 d5 b a# G6 Bto tt! Q% o. S4 k. Z$ Z
ask patches [set pcolor gray ]
; K0 ~& E0 Q3 M; `0 d: P& C/ A% cask turtles [set energy energy - 1]. h: W% q% h0 H% U- r: V& y
end# d5 U) @& t* i' G5 p0 A
3 G. h' I+ ?" ^# q. ?
|