请问:
V& j- p+ z! q+ W随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?2 |, x$ Y9 [; s) @' ?2 J
. U4 s' D% e0 l& D. u
" T! s4 D& ~# K9 i) X) k7 Nturtles-own [ energy ]8 c, l9 K1 Y; s
to setup
6 U" Q; s' w; ^' e" Iclear-all6 N% h4 E7 t5 _/ U
set-default-shape turtles "square"
" V5 c2 B! V8 x+ a X8 n; Acrt nutrition
+ K% i8 {8 E2 k f" q, x9 Eask turtles[
" t' ^/ J5 C7 K3 u% e; a set color white8 w# \& e3 a! C# H2 `0 I
setxy random-pxcor random-pycor]% r! i. o1 M! F& t9 c
. W6 ?0 ^8 |% Cask n-of microbes-initialization patches7 Q1 f$ [! T# J6 i
[ set pcolor green]3 M- U4 b7 I) R' U* Z) S
ask turtles [set energy 1]
" S3 {# q8 m* s( Cend
5 i( w+ _' P( C6 e+ L/ C6 G$ ?# l) [6 {) J! U6 u( [
to go
& c2 H( i' ~3 g( H0 a8 i" F" Q ask turtles [set heading 90 * random 4 fd 1]
( Q" |) L; e* X, V* }0 R4 | ask patches with [ any? turtles-here]
4 k$ z/ v E7 t5 w [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
! G8 O7 @4 S: ?6 k6 T+ _ ask turtles [ if energy = 0 [die ]]+ E, \/ _2 d+ ^7 B' Q2 A4 ~2 a4 y* r
end
, S* Y: m2 ~/ o$ d& G3 |- r7 Q$ S
3 y! f. X' o+ H( o! u0 Eto tt- z w- e7 ], Y" M( E8 U
ask patches [set pcolor gray ]2 B! z/ o. a# H+ Z A; s
ask turtles [set energy energy - 1]
* I6 D& c$ `' v5 l6 R2 Fend
/ [! [; ?/ O. K' }- U0 \& E2 J' n l5 ]
|