我编的程序如下turtles-own [energy]7 d' R" p3 \% _1 C9 N( D: O
to setup
3 t2 r9 F3 M7 _/ A4 v x clear-all
0 ^4 j; Q' D* |6 }" D/ w) ` setup-patches
1 v" @2 j8 D- r/ m" N6 x; ?" x create-turtles 100: f4 [( \6 E+ U0 H4 v. n. R" y( e9 c
do-plots
4 g) Y+ }& m) e6 h$ Q9 I ask turtles [ setxy random-xcor random-ycor ]) {: _; h2 l Z2 z* E, s1 M
end
5 f" h% M4 e6 `to go- Z) U7 p9 H8 K, S5 i
move-turtles# {0 a7 E4 i# m4 s$ ~" Z$ o1 j
eat-grass- i! Q b V1 P
reproduce
: E/ i: b# H" e* w1 F& d check-death% B" E$ w+ X: V7 `
regrow-grass2 c" u8 e. X) C- j
do-plots
% q4 V: D; ?$ C* P# V' M3 Q' \end
6 I- G0 P0 o( U* c& e. {/ [to move-turtles0 T5 E. S' ?7 q# t/ |2 I
ask turtles [# n L' h/ `! P% B
right random 360& k* z& v# M0 i3 g1 K1 r% ~) _& x
forward 14 P( S {& A/ @" T2 }, v+ ~
set energy energy - 1
3 Z; {8 V8 l4 t! T ]: t2 F; Y L6 W0 `2 s
end3 C8 S) y' ` I
to setup-patches, c0 j$ n. h8 x0 g$ J
ask patches [ set pcolor green ]
& e2 F& h1 B7 T Nend2 F {. R: W/ P1 v
to setup-turtles! S7 z" C9 G; f
create-turtles 1006 x* b- H3 Z2 i6 H/ I" r
ask turtles [ setxy random-xcor random-ycor ]
0 h: p3 V& y7 N; R5 Q! Xend7 u# ~: T% \! ?/ c. x5 u( n2 `* C
to eat-grass
8 a0 T9 u0 H3 u2 S6 i+ @- z$ l" j ask turtles [
% ~. [) d, M2 f: M5 s9 y' c2 {# E6 c) b Q if pcolor = green [9 ?8 C) `5 B$ z$ ~
set pcolor black Y# L1 Z: J: ^( g
set energy (energy + 10)9 C! Z3 {+ c9 D. E
]2 a! U% o3 G. j& J: z
ifelse show-energy?, C. C7 @1 `; }2 ^( f
[ set label energy ]8 `& O- T7 I6 ?
[ set label "" ]
) y) \0 w0 @. y6 u- [ ]; E& L7 F1 u: C! r+ S4 Y
end |& o6 {6 m' W5 t c) z4 m
to reproduce: P1 ^8 P& R+ X% R @2 E+ e6 c/ p
ask turtles [
, f2 x: `9 U" k* q if energy > 50 [1 c' h" { Z; z6 u' k
set energy energy - 50
5 t5 N# J) z7 U5 |* p c hatch 1 [ set energy 50 ]* F& L0 Y- W; Z" }3 W
]
. j' R, w# B/ B0 @1 l( C ]3 v! Q! }' D5 e
end: `3 Y# L' k) k6 k- s
to check-death
1 s p) H; H' E2 T ask turtles [1 O/ a2 [; E1 L% r/ o$ r
if energy <= 0 [ die ]: y/ e6 N8 H- _, D5 H( v7 _
]
/ p) b4 d1 W$ L, v! lend7 F+ N3 t# g4 C0 e2 C# u$ h
to regrow-grass( z( W. W0 D8 ^
ask patches [
}" F3 ~2 P, e# n4 R4 C if random 100 < 3 [ set pcolor green ]
0 e2 J* X9 w9 H, R0 K7 r# T, D k ]
t- s$ M# k# O4 Y6 vend
- O1 b3 s% [/ sto do-plots
& V! R8 E2 \ i a1 `+ b( ]# t set-current-plot "Totals"
7 t+ }3 E: Z7 K( l: e$ a5 @) e set-current-plot-pen "turtles"
8 I1 M: X2 Z2 C0 y8 @( r3 e0 R plot count turtles8 c% N+ j3 `2 Y) a! m' }
set-current-plot-pen "grass" s, T3 e' s* n" D
plot count patches with [pcolor = green]
) O" S) s* Q0 L! yend
n+ b- _" V0 l可是运行时提示no such plot: "Totals"3 _: z! o$ j; |3 A* u$ Q
error while observer running SET-CURRENT-PLOT
7 {* M& x4 Y$ d$ o$ R* H called by procedure DO-PLOTS
, |; }. G; O, A, Y% o; l0 a/ h called by procedure SETUP
" h7 G0 y' A" P) E called by 按钮 'setup'* L5 h4 |; w% w7 }$ y$ [
求大神解答啊 |