请问:+ L, s# B1 n! w+ x0 ^3 i7 h+ X
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
% c7 B8 t* ]3 n
5 ?- H' ?7 V6 q0 W w/ P $ w5 u5 {6 A# p8 s$ R
turtles-own [ energy ]
% Z7 P& {4 y, Dto setup
" _- t+ f6 s6 b( V8 rclear-all
+ Z4 q9 M1 F, B$ u- Lset-default-shape turtles "square"
W# P( F# W( @. [1 \crt nutrition N# ], h+ \) a0 a0 p. ~3 |
ask turtles[
3 U+ p% }5 v4 p# }3 m( k/ _/ O- }, M set color white2 y' a& p9 p @ c1 N
setxy random-pxcor random-pycor]. [9 ?1 l7 O; G& B
- }/ Y; Z% s" @6 y2 O0 }' a
ask n-of microbes-initialization patches
7 e# t. M, q8 b: J* S- d4 a! c [ set pcolor green]
4 }( `5 d0 Y# F& _' m ask turtles [set energy 1]4 E' v# L' F; G' Q- f: K; d
end
% s; E: Y3 V0 V, J" s- j: q4 w* I$ r
to go
! q6 c! m* o: I$ A$ _' W ask turtles [set heading 90 * random 4 fd 1]
! Z% `8 N, l# g2 }2 [( O4 U/ p$ y ask patches with [ any? turtles-here], k# X2 l9 r* a! q5 e! D
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
% H/ i0 u; a, V8 X5 {/ Q3 i ask turtles [ if energy = 0 [die ]]
- k0 y; ^0 R! }; N1 a( } end
/ U# t6 [- A* V+ K2 W3 s- F( r# B* E- U' t( V
to tt
9 n. g/ a0 r# \, c5 Q* g/ ]ask patches [set pcolor gray ]
$ l* l4 M Q4 [) }ask turtles [set energy energy - 1]. v) t) R4 B7 _- f( s% o
end
4 Q' Y$ K, Q8 z1 K" w* A! X1 T! o4 k
|