我编的程序如下turtles-own [energy]# d" v5 N. j3 u
to setup
# L8 [: a- U$ F( }0 G clear-all# V% ~4 ]; K. H; e/ Y6 k3 L
setup-patches' z; Z2 q% k* O% R0 m2 K6 ^
create-turtles 100+ h4 D J: ?7 T5 _1 t
do-plots, c' T0 m I5 ~2 o" a* p
ask turtles [ setxy random-xcor random-ycor ]9 \$ @9 \" u$ c, k5 O% s
end
% ]' D9 w+ ^7 x. mto go9 M9 k: ?& p7 ?
move-turtles5 O! @# ^4 w5 L0 V
eat-grass% G. L; S9 ]$ D0 x
reproduce3 _4 n, w8 _5 V9 m6 g% O
check-death
# m2 l- z+ V" J' n! g regrow-grass
: Y& Z: k7 o* x4 c' i do-plots
, r, z, m( L$ cend
# B& y- H& q0 `5 ^& g" hto move-turtles$ I- V5 U+ s+ q, k% F$ M
ask turtles [& T$ \8 f. q2 s9 s. E
right random 360
E2 m& D+ T f forward 1
' ~* }! {& P1 H6 p$ `8 W set energy energy - 1
( W [" h( Z, T; Q q) l ]
' G& Q7 f1 J, k9 S; O7 ]end
, j4 n* [: ?0 r3 ~3 b4 U) X/ e8 [to setup-patches
5 e8 c" E/ f. {* V w/ O ask patches [ set pcolor green ]# M2 }: b6 q r: N4 a
end; o1 t2 q/ }1 d- M4 \
to setup-turtles0 a; c8 ]& E! {( ^: _
create-turtles 100
% k3 R7 J2 P0 q( R' O' k ask turtles [ setxy random-xcor random-ycor ]
; {& } X- ~3 d' u" Iend
) s, h! ?) v! a9 r0 J% C7 [to eat-grass7 g$ R8 K/ y/ P: F' r% ~* e
ask turtles [
9 E; h9 d7 e! F9 W0 _6 d4 ]6 ] if pcolor = green [1 D$ c. M+ V& k4 B. \2 O8 L* m
set pcolor black6 M; S8 J k, @
set energy (energy + 10)
' b) ?' k. v) k6 ], [ ]
9 j4 q& K7 p# \+ a ifelse show-energy? z+ h) r( a# Z
[ set label energy ]# J, i5 t, `5 h% V. B1 v. t+ _! v
[ set label "" ]
) D; r' s- i# ^6 v9 Y4 s ]5 q& a x3 H0 ^; x6 d( F8 w; ~
end5 q/ W7 L: m3 \
to reproduce
- P0 U# s% X5 F) B3 d; V ask turtles [% k* J& h+ B: z. z
if energy > 50 [ S3 [% K( g7 @
set energy energy - 50% n5 I& e! |# z
hatch 1 [ set energy 50 ]
8 K" ~# ]% u5 H3 N5 L3 L ]& V1 o' n" }. C# s1 i
]
O( n4 L" H% B9 Z4 Vend: S% z3 i( z7 K$ g
to check-death6 {: R4 |5 l' _. D- w
ask turtles [
: a/ `6 v& i/ A$ U4 l& } if energy <= 0 [ die ]
1 c1 [7 h- L+ @7 z& \0 i' E ]7 E% N" }2 S0 W+ F3 d
end+ T0 K) q: W2 \0 P; ?0 f7 ^; ?+ H
to regrow-grass7 {: P, o8 {' d6 [
ask patches [
7 _/ Z8 S: ^% K9 w if random 100 < 3 [ set pcolor green ]
2 e |& `3 ] @3 U/ I ]. j, W1 a3 b! l! d, I" o ]; r
end
& d; k N) u; U% D$ C) L# uto do-plots: R' J) g: m: V
set-current-plot "Totals"+ f3 A7 h2 P( b& F7 P; A) I1 a
set-current-plot-pen "turtles"
( H6 y( t9 r8 s* Z3 f1 y plot count turtles
7 c0 x% A H' I# |5 z set-current-plot-pen "grass"4 ~. }& k3 \8 j4 n
plot count patches with [pcolor = green]
& O* _4 J: s+ J% N2 }0 r9 Oend' o4 L" s) l2 s3 t
可是运行时提示no such plot: "Totals"% q* o$ }2 {* w# x$ W
error while observer running SET-CURRENT-PLOT/ a- @6 J: M1 X
called by procedure DO-PLOTS
& A7 I4 l- i" d3 g' M8 Y8 X! o called by procedure SETUP
0 f+ O# Y5 V6 A# e! o4 f called by 按钮 'setup') q0 B6 U0 |2 \' M+ T0 z
求大神解答啊 |