请问:
7 j) O3 l. D3 }% G6 Q8 w" }- d随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?
S. g. G2 W; ?4 G* {
# [& R0 }& a8 G; P8 }, r 6 |2 Y7 Y& i' Z. ] N9 x% R
turtles-own [ energy ]' g: ]% {; d" }) p6 r, _! _' D
to setup' G4 u' g1 g5 Q3 Q( `( m, @7 z
clear-all
3 \ y' b) R' X* w8 [set-default-shape turtles "square"
R% |7 `4 o3 l" P, s/ F9 d( N+ Ocrt nutrition$ y) p0 [8 W& R6 U w: `' h! @
ask turtles[
6 L y s0 n5 |4 r set color white
% d: j7 W, k ]! [* w6 w setxy random-pxcor random-pycor]) S2 e- V, z6 S% T- U& q
8 `) I2 \2 Y2 x6 eask n-of microbes-initialization patches
1 @; x0 M6 ?- h P' J5 c3 H* M [ set pcolor green]
* {+ s" I) k. @; C- E8 N ask turtles [set energy 1]6 q' n, Z3 x8 g% X, t, [
end
# L& X" n5 T9 }8 A- n g- }% S4 J5 O8 s
to go9 G# d" E. r. }8 R6 O
ask turtles [set heading 90 * random 4 fd 1]0 l7 O9 R; \* e
ask patches with [ any? turtles-here]- |4 w1 k0 k+ E5 @
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]) Y: n3 F) F2 D6 l
ask turtles [ if energy = 0 [die ]]
6 Z1 o2 _+ _) I" N end
4 c% N! X5 H3 @! |" W
" `% g4 U/ M# x. i: Z$ sto tt
0 P) w. {& ?# g) k0 Bask patches [set pcolor gray ] I: T, F; \( a: J0 j/ F7 X H/ y- R
ask turtles [set energy energy - 1]1 n) Z- K, U& v% w" w0 D# n2 t
end
; [) o7 D& c: f2 L, R: f- A* e" R2 n' O+ [, h
|