请问:. _% n' Y$ r' f8 V+ f: p
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?* a8 S v' E8 I! P+ T6 _- x" o+ }3 X7 |
' Z1 Q' D0 U! n0 F
# w8 |" D" p6 I, P2 J* W1 o
turtles-own [ energy ]4 M' P3 t1 u3 k% p& _
to setup
. y! S5 e4 t) o* x sclear-all7 G0 g% f! M T3 B0 U) T: `3 h( L
set-default-shape turtles "square"
- ^% y% p) i! |& m1 d2 qcrt nutrition
2 W! ?" I' a0 G5 Z3 v' cask turtles[/ F- _4 h' ^( W0 g- \6 d8 a
set color white
s" N' H1 e. ?/ y1 ] setxy random-pxcor random-pycor]3 l$ s- T2 E8 `( I9 s3 E
4 k5 t! S5 O( Y
ask n-of microbes-initialization patches5 w- i0 i: W+ L: g1 z9 ]) U' z! s
[ set pcolor green]
7 z0 W" u y5 M( Q+ ^# x ask turtles [set energy 1]
6 d: l# O. ^8 O6 x' k5 Kend5 x. i: F! \: R& [0 g. `
" P6 W, q- e" f+ F2 t) s3 sto go
9 A0 ?( _9 q3 x) f R9 k! k ask turtles [set heading 90 * random 4 fd 1]
: p" s. C% G$ k ask patches with [ any? turtles-here]
\9 W4 r, M: y! W" x7 z! F [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
( Q1 B, A; N8 R# X4 `0 S ask turtles [ if energy = 0 [die ]]* w& T r& b. g; h, L! c
end
3 g: {$ H8 A, `- R/ E4 X3 W
7 p/ R" u9 f: Vto tt
* I) J- o) c; X" @$ F! N0 gask patches [set pcolor gray ]1 n; G7 u& e! E3 D' d
ask turtles [set energy energy - 1]' R+ t. j) i( s7 [1 I& c! Y- n7 G
end- |0 E8 E' H8 x0 e$ {+ I. _# A. ~
+ p* V+ g4 l; X: ~
|