请问:
) H( c7 K& f: Z* C z$ F& {, ~4 t随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
4 U/ W4 B+ c& k2 V
7 {0 z- \' j& H2 J: _
! L% o& Y4 p8 e" @3 F5 Uturtles-own [ energy ]
$ l/ V$ B' f; i& _+ q/ L* Yto setup e: O1 t. H: x8 {
clear-all) v' |, f7 D$ T+ h/ b" o$ X. c
set-default-shape turtles "square"- ~* N$ [, T7 K6 F) d! v
crt nutrition( W9 I2 d6 }1 u( `% a$ R+ u0 l
ask turtles[
( k$ c+ x6 f$ l8 A2 [, f4 G; R set color white
! H! E- S4 v0 x, [" b0 g' y0 h% y setxy random-pxcor random-pycor]+ T8 U/ _; b2 `4 G
$ C' I8 i1 v& S0 }' [
ask n-of microbes-initialization patches
* O& z* a+ E% |* ^ [ set pcolor green]& Z$ x8 Y4 a( F
ask turtles [set energy 1]
5 p: _! q( ~- F1 N( wend e& M; ~8 r; U) _
' P n# V$ @1 S: i# yto go
8 _4 h8 k$ U5 Y& H ask turtles [set heading 90 * random 4 fd 1]
! P) x% P$ d3 N& X9 Z4 M" S ask patches with [ any? turtles-here]% `; r; _2 e; h9 t6 v0 Q7 R. i
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]1 E# D' _6 @3 H4 L9 s1 E
ask turtles [ if energy = 0 [die ]]
& R& B$ o8 c- |1 T) Q- `* m end
) s9 w5 q: n- Z1 K# C1 B! Y( b1 }
( L, N3 I$ U, y$ vto tt
: W1 u* H2 B0 s- p. T0 b" v; Vask patches [set pcolor gray ]5 ^7 q: g b8 y) c, u7 _8 m3 {
ask turtles [set energy energy - 1]4 N: ~$ M) O! }- o# ~3 N, L
end
. L1 E6 k7 n+ H, l/ u
( A+ T. }0 q7 P |6 | |