请问: R& X. U( P0 K# }
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
" g0 B8 B1 S" m8 K& [8 q1 W( Q( b w- r- e% [& Y1 {2 ~
! v1 x7 H7 S( h' b+ u4 |turtles-own [ energy ]
# }* J6 u- m0 \, A. eto setup
4 S+ e" ~+ W$ `clear-all4 K ]. `. }: W( T# a7 w, d0 k
set-default-shape turtles "square"
5 [" w# J C- \' S% C7 K$ `, ~crt nutrition
; \$ R# v2 f5 w- @+ Gask turtles[
; n! N# Q: K; b6 `' M set color white
" C0 {3 U, O! m6 L: q [; l setxy random-pxcor random-pycor]; J9 k0 C! @3 D& }. l: s; y9 p& h1 h
/ S0 b) _% A& Aask n-of microbes-initialization patches0 o4 V& C8 T+ W* h; l7 \1 @! x6 X
[ set pcolor green]
2 k4 M) u Q. `- C+ |6 V4 K ask turtles [set energy 1]
& O& S( W! x* s6 ^; U; ?end5 X# [3 U* b& w0 I
& D2 ^7 |1 M% g Y8 p# T
to go, K/ C8 i; o6 F2 N5 y
ask turtles [set heading 90 * random 4 fd 1]% k x% M ], t& }3 s6 t
ask patches with [ any? turtles-here]- _% `( x2 e' c" Z: @$ K
[ if pcolor = green and random 100 < chance-of-congregating [tt ]] w( S9 j. l, B. d
ask turtles [ if energy = 0 [die ]]
2 U h. [% K8 N ~/ c end P, [( p. P$ O
4 M/ }9 h7 Y2 W8 d3 R! c) r( Lto tt% [- Y( P0 V Y$ G
ask patches [set pcolor gray ]
/ Z' A" x; B; _5 @/ r& M" ~ask turtles [set energy energy - 1]
$ U$ }# ]1 R2 b% {end7 L9 F0 a2 Y9 X5 \9 h
) I ]0 P6 b e: L
|