我编的程序如下turtles-own [energy]3 r. L' g: H: q- t6 B) u; o
to setup
. w i1 E. D2 i1 y; @* w clear-all' r! N6 d1 H+ Y1 |- B
setup-patches2 L2 h- j. o; N3 `. s
create-turtles 100/ H( Z- ~# z! Q" T$ M
do-plots8 O l6 q2 e- a! u" M# g7 ^ a1 o
ask turtles [ setxy random-xcor random-ycor ]
3 `6 z* L3 @( D4 q/ A; `end
7 _3 d8 b; {& I$ S+ e, r. uto go! W! r$ ^1 |2 n: G: i0 d1 Q
move-turtles
2 {+ {: b3 h. U/ j+ F* V { eat-grass
6 R J" T5 H+ j7 E4 @2 u reproduce6 q8 Y# Y4 Q" y$ j+ Q$ ]
check-death
( D; ?1 B6 Q4 g$ W; [ regrow-grass; a3 W' T T. z I7 C
do-plots8 y! V& M: u q; ]" j j
end
8 y% `+ g$ O* Mto move-turtles% _5 ^/ W0 A. J% r
ask turtles [+ `7 |+ v. i I: `' ?- `
right random 360
1 ^& T2 T* f- f) z forward 17 x" }; v' F5 J: |. k- Q
set energy energy - 1% a0 v) u' r: ~5 T. V: P
]
* |4 e. N7 r3 w# B7 U" N9 T( Aend
4 _3 A" x# f( f+ o+ S& {, eto setup-patches. K3 X& L* k/ e$ |% K2 s! |/ |
ask patches [ set pcolor green ]
3 i) P' q9 F! c; o1 X) A! Mend
4 c% J5 Z4 p9 E4 Fto setup-turtles1 v, D( l3 Q! @ ^9 {# @
create-turtles 100) A, ] H, q1 L/ i$ _4 X
ask turtles [ setxy random-xcor random-ycor ]1 K3 }! `( u6 B: q+ z+ r. B8 Z
end
; Y% }9 q/ Z6 X$ Xto eat-grass
# t4 Q* y2 ^! L% N+ H! P7 [ ask turtles [( e0 S; S) `) J( q
if pcolor = green [
: b" i) K' n. [+ _ set pcolor black
: p0 E% v& \! S+ f. y, n set energy (energy + 10)
5 |- C/ {7 k, L9 a0 `: W, ]7 N ]3 J) b7 ^1 H; n
ifelse show-energy?9 ~. p0 M! m6 _9 m! {
[ set label energy ]; B7 d7 D8 `1 R: d" W
[ set label "" ]
) t; s! L a$ {$ f/ i ]
$ b( \0 a$ ^. G) H3 T) _6 C2 C/ Rend
0 m0 D) i: t8 cto reproduce
$ X" r" }6 d( U/ D1 f ask turtles [. v( [" D- b" T+ G6 k
if energy > 50 [
! Z) P A/ U2 X) ^# R set energy energy - 503 o' U1 C: V9 D3 g
hatch 1 [ set energy 50 ]
& ~$ ^' {3 Q( l: } ]
+ _2 `5 t9 V% ~0 i ]
( a" j6 f, b# k( ^3 Bend
+ ]- @7 H1 u' \to check-death
" d/ L- l, x7 V% m1 Y ask turtles [# [: K) o& }- K& z2 u/ g( p2 C) V' y
if energy <= 0 [ die ]
1 w% x# w) `9 R1 Z0 B& | ]1 q% O3 J) V3 Z& y
end" i7 ?0 s! j, [1 K1 O. ~
to regrow-grass
1 a" l) E8 g6 u, }5 | ask patches [
4 E( t6 P9 b4 f; o: p3 z if random 100 < 3 [ set pcolor green ]4 w0 v* ], O3 a M- s
]
% {7 \# p, Y0 S: _end
6 ?/ H( T/ ^; K7 xto do-plots! g; E0 x* I1 o0 K, U0 m' _
set-current-plot "Totals"
5 T3 ]3 S& ~) F" K! O. U set-current-plot-pen "turtles"
, n5 I8 K8 n9 U+ j plot count turtles
* W$ P |" T* B; c( H set-current-plot-pen "grass"5 k& d% S* k! g
plot count patches with [pcolor = green]
* k" o, l! Y. k7 F3 \end* g- V# z; _4 P; y5 X0 H
可是运行时提示no such plot: "Totals"
- B/ {- o3 r1 K. u n7 terror while observer running SET-CURRENT-PLOT
' k; [6 p& Y# @3 Z0 G called by procedure DO-PLOTS
- B0 z; Z; [/ k0 f0 W/ u6 H called by procedure SETUP
, I8 E. y* l' |& g called by 按钮 'setup'
7 p( r4 X' |* q8 w求大神解答啊 |