我编的程序如下turtles-own [energy]4 ^! D4 l! y' U5 j* c, P
to setup+ B: m# E2 V0 T; x# N+ N
clear-all, L+ i5 G' L m; e- i
setup-patches
. t! p" D2 L! ] create-turtles 100( J2 E4 a6 ^2 J! @
do-plots
. i* i: ]5 A8 a2 H0 t ask turtles [ setxy random-xcor random-ycor ]
\/ {- i. m3 Rend
/ V- r3 ]/ o" L S3 |5 \1 Cto go6 W# m, ~3 Z p6 v6 s2 Q, H/ Z5 W
move-turtles
6 A+ h, Z" v# m% }% J0 C eat-grass, x; L, v* Y2 Y4 y0 w
reproduce
! U$ L$ p: u$ r4 Y; ^ check-death
% I/ c( r+ o# S. Y4 H& J3 V regrow-grass
- k) K4 z! K$ ^7 }' g do-plots. z! r( K8 Z$ Z+ g/ j$ c
end
$ M* R0 p( }' A1 |! xto move-turtles: g5 f1 u- |; \: i
ask turtles [
# ?1 |0 Z: ]: I4 x7 L right random 360
) J4 R& l% a& l# L forward 10 Q, a# L: ?0 N$ G' ]
set energy energy - 11 k$ O: ]4 c1 I4 u5 y9 F6 T7 w6 t
]
F# n& a) Y7 x! wend& c/ o' v7 v2 g( v$ P. G& E
to setup-patches
4 @8 \" \/ G' d/ }* j ask patches [ set pcolor green ]
1 e4 f- [0 [0 q2 Q! i0 ?end1 Q, B! I, _- g% a2 l+ L5 q* K
to setup-turtles0 w7 M2 u, G! s( o# ~9 {
create-turtles 100% ]/ d- I- Y3 t) @/ v" z0 w
ask turtles [ setxy random-xcor random-ycor ]
1 u6 K7 D( e1 V3 m: R# M' X; \end
6 Y4 Q* b: {" O( H$ A3 D0 ito eat-grass
) i* B3 z1 N4 Y+ ~6 t; I0 A ask turtles [( v+ i% `5 G" J8 h' K2 f
if pcolor = green [
7 Z# N* R' Y; ^) v+ j8 ]0 M; i set pcolor black
9 E) |' {, u1 l9 a/ L( r set energy (energy + 10)
' L9 C/ w! n7 p* P# b8 E4 H) l( F- n ]5 j" R1 E0 b1 [& ]+ U7 Y0 w" ^
ifelse show-energy?( U& h2 _/ Y: ?6 p, ]3 U& G' f
[ set label energy ]
* T0 ~0 w4 a$ l4 R% P2 K [ set label "" ]/ I! h. ^& {1 Y& \0 y
]% y" a- U; T# c( _- t
end
: ]" H' [( o, ^* @5 E: J7 Wto reproduce' g4 s5 r( M* r6 f0 I5 ]
ask turtles [# Y: A% u5 a2 j* O
if energy > 50 [* P/ c0 G, K" T5 U
set energy energy - 50: s0 o( R& }/ P* Q3 B2 s6 }# R
hatch 1 [ set energy 50 ]
$ M `& b! ?; M* \/ R5 @* x ]
. |1 O; o# r: N- A9 G- G# I ]
$ L- W( S# Z4 y4 o5 Oend: i* N: V$ H! m( s" S- o3 r' p
to check-death
# V' F: L2 U3 k* Q! j; T" @; e' ?+ Q ask turtles [- n, O* v" p# z7 R
if energy <= 0 [ die ]
) O2 ]3 U. f5 K5 l u1 ~2 ?/ Z! r ]
0 X1 m. [0 F6 ]) W/ x2 z. r9 f3 Z, Qend, c( F& a" ~$ V3 A0 s" E" d* ^( y
to regrow-grass
& a6 F7 j, g$ J3 y% ~2 E$ c ask patches [
/ ^1 u6 x! f& A3 L: f" r& e if random 100 < 3 [ set pcolor green ]
; F/ v# F1 n% O T" D- y, [" ~/ m V0 O ]0 u; f1 m& `* l& }2 J( }9 ~
end5 u1 w- Q. g' m5 @5 y7 M- ^
to do-plots
% p# e v, g! B$ N+ L- W. h- Y set-current-plot "Totals"9 w" k% Y' h0 z
set-current-plot-pen "turtles"
# {- q$ W/ n$ f4 f9 g! v plot count turtles0 e! U4 ~' p. i# U. @
set-current-plot-pen "grass"6 o3 ?6 R' Q0 y7 x3 d
plot count patches with [pcolor = green]( ^) b0 F% I! V
end- o6 E& D9 V. z
可是运行时提示no such plot: "Totals"+ B. a' }/ S8 Q0 g! p: H
error while observer running SET-CURRENT-PLOT1 |+ E2 J1 y- d
called by procedure DO-PLOTS
+ g- o2 S) ?5 X$ A5 K called by procedure SETUP. v- p0 G% l2 |6 A, u6 f/ t
called by 按钮 'setup'
1 [: ?2 `& c0 R6 A求大神解答啊 |