请问:* ]* h; e7 o+ V$ X8 |
随机产生的turtle 已经在patch的坐标上上下左右一格格运动,当turtle碰到一个随即分布的patch以一定概率粘合,patch变色,其他turtle经过也还是以一定概率粘合的,粘合后turtle的能量就会转变到patch上,并且以一定速率消耗它,怎么编写这个过程?下面是我编写的,运行时就出错了。怎么改正呢?: r6 C& t3 u3 \ Q; h6 F
4 q* s: a' d: b- B& s
0 L% @: L3 }2 S5 Xturtles-own [ energy ]8 t0 q5 h+ [6 J( s, I% U
to setup/ O+ G/ w$ ?, s: _& X- _: _/ p
clear-all
! u) }! `. [' H# i% P: {" C- G" Eset-default-shape turtles "square"
. l# O$ C' _2 S4 D$ rcrt nutrition
! j5 H- c9 y/ p$ Mask turtles[/ l9 K Z* }$ Q3 a3 P
set color white1 U6 \8 L1 U% H* _
setxy random-pxcor random-pycor]
9 x9 r4 p9 r8 V- h0 c/ f : w# l3 G8 c& Y, {
ask n-of microbes-initialization patches
, c; \( H/ O! O$ [+ Z% \ M% _- D3 G [ set pcolor green]
, Y( X0 }) I; r7 V2 O ask turtles [set energy 1], M9 Y" E% L# s9 m7 ?6 f& z
end
4 o# o0 d3 H1 O
) N/ w& I' t+ s/ x6 V1 Eto go/ g/ X1 A4 |& y% w/ ~: c
ask turtles [set heading 90 * random 4 fd 1]% _ A9 ?9 {$ L+ z8 o$ `# \
ask patches with [ any? turtles-here]" I! Q) ^( d! W7 S6 j0 C: o
[ if pcolor = green and random 100 < chance-of-congregating [tt ]]
2 n1 q! b: j! | ask turtles [ if energy = 0 [die ]]9 ^) Q" h' j( Y3 F
end
3 i9 ~8 ~# K9 b5 h$ ^9 j# D$ _0 m! P) J' a% p J& E+ {
to tt/ X+ k* }$ p7 r3 Q$ b4 Z; [
ask patches [set pcolor gray ]
) T2 Q3 y9 v" I5 {& xask turtles [set energy energy - 1]: {8 [9 N9 v. y) {* m2 ]
end
* f I$ r. E& W! P: y6 g5 _, h* b! B" ~4 J- A- v
|