请问:
$ f# y. P6 a6 i" v& N( X随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
$ @5 o5 E4 D/ x! k3 R1 o! U* j- ?& P3 T6 b6 |2 @
; k l+ K4 Y4 l! s. v1 u$ ]3 g
turtles-own [ energy ]
% u6 m. \5 q* t2 j5 |# l4 f mto setup7 r0 L5 x6 y, A: H5 u( \/ A
clear-all
. j% B2 a5 L m. uset-default-shape turtles "square"
% s4 u# t1 i" M; k! c8 \' Tcrt nutrition
, D: v: u9 ?& k M+ dask turtles[( E& Z, M! s$ i
set color white
! c( P% U& i# X5 {' j' x setxy random-pxcor random-pycor]2 j& ]. a7 f/ P" g. L6 y
h) g8 H% W" {0 hask n-of microbes-initialization patches
, C+ R* b$ j1 ^% P* r# {. v [ set pcolor green]
) h& C$ Q3 B( R# K& a! _ ask turtles [set energy 1]( p0 q3 e: C, j' Z
end- i% W! s# Q% B" ~3 M
/ h3 \2 @8 o9 g; c
to go
: Y, c9 \9 S3 u4 ^ T! ? ask turtles [set heading 90 * random 4 fd 1]2 u$ y% W0 X4 h9 A+ x0 _
ask patches with [ any? turtles-here]# F2 j* E5 ^. l3 t! u; ]
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
. b. l/ V. \1 G1 {* _, u- \$ [ ask turtles [ if energy = 0 [die ]]& [8 ~5 j% j ?8 Z7 G
end. `+ ]3 B/ s; Z {
. ~" Q0 y) N! \9 G3 N7 c$ Uto tt- u4 L: }) e [# K6 @; ^$ I' o4 ?
ask patches [set pcolor gray ]* P/ X" y3 l( g2 x+ d- n( m9 }1 @; V
ask turtles [set energy energy - 1]. P4 l3 ?5 O' F3 I8 [; {. d0 Y
end
" c- g; a* c3 T1 [# t
) u4 O. K! h \" Q |