我编的程序如下turtles-own [energy]+ Z3 N' L+ k2 i. U
to setup
5 l, y4 b$ ^5 e4 ]$ Q clear-all: J7 Q- c" ^4 I
setup-patches
, z& b% h6 ]+ u: Q) D* c) }3 [ create-turtles 100) Y7 }- S+ N0 s9 l
do-plots/ z: N% B2 m/ N% N, e0 d
ask turtles [ setxy random-xcor random-ycor ]5 t) E! _! o) ]( ]) K3 n% m: E
end
9 z V# e5 R0 i) ~! U8 Tto go
P+ p3 g( }+ u* b move-turtles
/ V* l$ F* n1 D7 i eat-grass7 Q, W( N! [: {/ R( r" R
reproduce) z% b* Y2 m; f3 i+ x" \. ?
check-death
1 j. f D8 ~; _6 }# F- E8 Z regrow-grass& |, p' S; I- E; U) Z$ ?( R5 J
do-plots+ Z5 l: w/ N; k& [, O7 u1 S0 k8 o
end
3 R5 m' @& ]5 u, ]to move-turtles
; b+ r% z* n5 W; T4 e ask turtles [5 `9 m) A2 |' Q4 p
right random 360! j; X4 b1 c4 E$ x0 o& X
forward 1
* N- c2 c; N6 o$ I! [ set energy energy - 1
& h$ w+ L/ X. Q2 F ]
. V5 L0 m; x) m8 p9 }end
# z% F4 q3 h; \0 O& uto setup-patches
) x- g/ v$ i6 }5 z8 ?$ s- T7 s) E ask patches [ set pcolor green ]9 _. J' b" R! {0 H( S! _
end/ Y2 p% F/ ?4 J
to setup-turtles
% X8 V+ ], p, ^, @4 T8 W create-turtles 100
7 K, W9 Y) q( z0 o9 h8 r) H/ [5 H$ h ask turtles [ setxy random-xcor random-ycor ]: ?! U/ ]8 \9 ^, f# r+ T
end
/ t7 [8 x7 `! d' v/ _9 Rto eat-grass' }' d! M2 A% e) {+ |" J' q: Z/ f
ask turtles [
- C2 R m8 W5 @3 x* f9 K if pcolor = green [
% ~7 h" }* H/ F5 P0 l; O set pcolor black
! B. h9 k) B$ U1 m- b set energy (energy + 10)* W: f7 V5 S" r9 g9 Q
]; Q( c. i$ H2 k( ]
ifelse show-energy?: `; r0 B6 W6 T6 \- H9 V
[ set label energy ]+ a1 X U/ u3 _( T; ]
[ set label "" ]
% y% Y- g4 Y2 R2 @9 ?- ~! V ]
1 E; D! ~) R1 y0 Zend
; G6 Y$ l( s+ ]: R8 yto reproduce1 D% z. [. H1 Z: E/ u3 K
ask turtles [7 m% \3 U4 c1 m5 D
if energy > 50 [; g L3 G* D( Q! J8 q% f
set energy energy - 504 |* l! c5 L. N B7 F1 ^
hatch 1 [ set energy 50 ]; [! M$ O$ m0 g- ]: Q f
]
, { {" t" l0 J# i7 N2 ]. R ]
1 ?: H) {0 I+ e: o! hend
% p! o/ {8 z4 X8 z0 [% i8 H+ ~7 Dto check-death
3 y- F1 ~9 B7 V- E! E) _* c ask turtles [
9 S0 @" \0 L! [. Q if energy <= 0 [ die ]
: l8 L2 y& m* p" v7 W) O ], l- F* p+ F; j$ p4 N5 I: V
end9 T5 x8 H1 e# Z V+ ]
to regrow-grass. W+ B- E% ?) o4 C* S9 ]4 [% R
ask patches [
! ^$ ?8 f. E4 m7 b$ x: R if random 100 < 3 [ set pcolor green ]
' l7 L6 O9 a4 H# W: Q8 l ]
; k! L# b0 m/ F0 h5 X& Fend7 [. v! w' P8 p4 B( e9 c7 L% T
to do-plots5 C% V, z2 z) v% v
set-current-plot "Totals". M& ]. N8 H m( c
set-current-plot-pen "turtles"
: l8 w1 ~4 j/ z' F plot count turtles- d; a5 @) ?4 l2 ?* K" K# S
set-current-plot-pen "grass"" K* h+ h( j4 u3 s+ ~& f) O; P
plot count patches with [pcolor = green]
/ u$ w) _# ]* w# e3 U. W% t/ jend" A% \! @" f. y" Y }" F" X
可是运行时提示no such plot: "Totals"
/ n7 ]( A0 E2 f% [6 K- r9 Cerror while observer running SET-CURRENT-PLOT
- h8 }% W/ k7 ~9 o6 N called by procedure DO-PLOTS6 l k4 ?; i1 N8 \! E- g+ O. i
called by procedure SETUP7 E$ b5 Z, u, _9 w
called by 按钮 'setup'
/ |& G* i% e* h# D/ R2 v求大神解答啊 |