我编的程序如下turtles-own [energy]& e. _ I2 z) y, O( F+ I
to setup6 b6 q7 o, {7 M# \- [' e
clear-all
3 k3 Q, D* q* e. @6 l$ D6 X setup-patches
, ~+ a5 D$ i) r( g create-turtles 100
; d% d1 v" |! V1 C+ y! o do-plots& {! r* a: R; B$ |; I5 P# q1 b. ?
ask turtles [ setxy random-xcor random-ycor ]
; G8 S. r' c1 s; E3 Zend! R" V) F' D7 W t
to go/ p, H$ B& @- `# O
move-turtles
: l( T. c# s$ y, U, S# o, \; y9 H) I eat-grass2 ^( r+ k% M) W0 }2 y) j* v9 q
reproduce
% V% w- [$ B7 ~# N2 ] check-death
; w0 R- z" k9 r: g" N regrow-grass5 S1 x9 a4 _6 K5 t. S6 y3 ^+ F
do-plots
( G- Z$ `1 b7 T2 ~$ J% Gend. D: [6 D: ^* X8 f! q
to move-turtles
0 a: r& I+ T2 L* E* @; Q# o ask turtles [; ~& W' K1 p. f& \5 _5 t
right random 360
2 `5 J& Z8 \ o7 x% \ forward 1
. I0 k& |( N2 j' ~% _4 U2 m0 { set energy energy - 1
8 L9 {3 x7 u0 |4 { ]" N; j8 R/ J/ ]+ Y, O) d
end! a# H7 \8 A/ ~4 r& L. O
to setup-patches7 A- U8 j5 V* A, h9 ] d
ask patches [ set pcolor green ]
4 z% s. }; x4 ` oend+ x0 `- Q4 _9 g/ `. X5 ]1 W
to setup-turtles5 ^1 a" r, p0 k5 d8 y+ o
create-turtles 1001 O, m& j) L# {" L& t: \% C, y7 m. @
ask turtles [ setxy random-xcor random-ycor ]* o) c4 m" k% @
end7 i4 V7 V, ^6 O7 G4 d' z
to eat-grass. q' r: w' ~; z! t
ask turtles [
' Y' ~! i- n* [9 A: M+ { if pcolor = green [. R. A( k! q5 x2 e3 C% E
set pcolor black
. x& f+ y& Q" h7 W set energy (energy + 10)% |; J7 o" L& j* t6 }! R
]9 c9 y7 L* n4 `7 V" P
ifelse show-energy?* I( u4 s# o+ p% c ^1 D
[ set label energy ]) x) i( \3 |6 h! e' u4 \1 `
[ set label "" ]' Q6 A5 C) f' x4 K4 x) x$ a
]+ q+ A& P8 s$ {- ^$ ]5 e$ o6 z
end
$ M& M- s' O) u" vto reproduce
- @4 l8 B3 }3 E; c; W. P ask turtles [
3 N, U& P$ e8 I0 E if energy > 50 [
5 }; _1 X! ~ N0 e; H* B! o set energy energy - 50
& X3 h' ~8 u1 } hatch 1 [ set energy 50 ] l) ?# }1 {% ^8 D& s$ T, o
]
7 b% O. P" x% c- \) f ]
+ O% H# t: x6 I+ |; _" _5 L) lend6 E8 g% J T3 e% M0 s1 q
to check-death
! s$ M+ v9 e+ W) |" V0 E ask turtles [' O9 I; ^/ }1 Q
if energy <= 0 [ die ]
2 R" x+ Y- ^$ l ]0 ]/ H1 l" [; F# ^! r9 I! m
end. L S" p' j! f! @( ]
to regrow-grass+ s6 }) x" h# P" p+ e, }4 b: I% Y1 C
ask patches [0 M) C m, n; {& d" Q& \5 `
if random 100 < 3 [ set pcolor green ]
7 W6 L/ P; ]+ k3 Y# n D; t ]
( W; {4 e, `* @, _! ]% Z2 bend
# f6 c, ] A2 Q I8 qto do-plots9 {+ l: U, W8 p B0 m7 `0 h6 \
set-current-plot "Totals"
* D5 g, _: f- o set-current-plot-pen "turtles": N3 T0 Q% ?/ X9 [; g
plot count turtles+ r* l; i6 D6 R% g* C/ o; v
set-current-plot-pen "grass"5 v4 ~; f) J" H0 A, { c, w& w( [
plot count patches with [pcolor = green]
; K3 d4 j9 X, Q$ W& C% gend5 C5 B7 N, J7 r% I0 i
可是运行时提示no such plot: "Totals"
' a" B, d" c2 M7 W7 Q* I: Gerror while observer running SET-CURRENT-PLOT
5 t+ p6 E3 }: z) p S4 m, C called by procedure DO-PLOTS
: ? O- _* N, \2 W7 B called by procedure SETUP
X# X" U: F K9 l/ u called by 按钮 'setup'
2 ^8 O$ [6 A) W& |3 |求大神解答啊 |