请问:( _) h: A! q4 c+ }
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?, m8 g- y! A+ h' V: f$ F. B
4 q5 e" U4 W1 n
! G" q2 i E' r u3 t6 A% c; N
turtles-own [ energy ]2 `/ S2 {9 b! `
to setup
. T' b$ S- X! D: J* c& J2 hclear-all8 J3 O' Q2 Y- _. I
set-default-shape turtles "square"8 W n/ D2 Q4 q; {* @
crt nutrition
* h+ I" Z( t( }* }ask turtles[
$ O7 z2 M# j! ?; ]6 o: J set color white5 }. w4 T1 c, R6 ]0 ]) D
setxy random-pxcor random-pycor] D" n/ W$ b' H/ a* C
9 h, E3 T w* f0 q
ask n-of microbes-initialization patches! x( O, L0 Z9 E1 C4 F" a$ x2 q
[ set pcolor green]! d3 ?- b7 g; ~+ l( _2 h6 V
ask turtles [set energy 1]5 K8 T) _0 ]& \0 }5 i
end
; L- j9 q9 V" b p1 W
1 _& P4 h! b G* A( J& Vto go' C x$ u% A0 t" E; X" g) x0 j" g3 p. b
ask turtles [set heading 90 * random 4 fd 1]7 m$ t4 ~+ W) z' A4 w" x
ask patches with [ any? turtles-here]
$ t' h- P# E9 @2 o: X" I. g [ if pcolor = green and random 100 < chance-of-congregating [tt ]]
. p' n5 M! H- q2 b; { ask turtles [ if energy = 0 [die ]]
- W+ m8 K% H. ~+ G' I7 T end
+ D% W& ^- X- p% v2 T, P
& I0 m% h$ P) U8 r# cto tt
Q6 j1 M0 q, V5 ?1 Kask patches [set pcolor gray ]
0 T1 G" e6 u! v1 s f- V0 qask turtles [set energy energy - 1]: Q1 n# l/ C" d0 @
end( ^' Z, A7 a0 j. y% m, F3 B8 N p
- U) W$ J( Y/ W- t- r- y* Z |