设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12288|回复: 4

[求助] 自学中文手册时遇到了问题,求高手解答

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
& L; f1 n: n% g2 yto setup
) ^6 g2 Q- ]* c) u' z/ [( c( U* q  clear-all6 B+ h% n$ p" i4 e
  setup-patches" W* @, I; A3 g
  create-turtles 100
9 `" z0 B, C1 `9 s& K% |  do-plots
+ D+ [3 K! q: P( n4 `  ask turtles [ setxy random-xcor random-ycor ]
- ]) Q8 r9 f/ \. O/ `7 Iend/ y" s% o" H' p3 m- p7 h) R
to go
/ S, F  `2 O* m* A# v  move-turtles
, `8 H# z/ D+ ^0 a# W6 s  eat-grass
- K$ m' O/ }' `0 ^7 ~* ]  reproduce! l: G. E; S. F  s2 [
  check-death
% u4 S5 A' [8 c5 S6 n. W; A  regrow-grass& i8 V, j. u9 B& Y+ m$ Z
  do-plots- i4 o* @# Q4 w1 c4 b' f& A
end8 G% a0 i9 x5 J! V, i4 a, a7 C
to move-turtles
# C; e4 A* y( v& l7 [+ R  ask turtles [( L' n1 p4 p, k+ E8 \  `
    right random 360
: O; M% e; Y' \8 n! Z    forward 1/ S4 G. s% O/ a
    set energy energy - 12 H" f" p% B& M3 p) Y) ]/ c: ?
    ]6 E' [0 r7 `; t6 S
end
  q1 `+ q" g) x. H$ a) Mto setup-patches. H" O: N9 I5 t+ Q( a4 U
  ask patches [ set pcolor green ]1 _. c2 Q- X2 Y, E, S( `2 h
end
: K! `( u" U" Wto setup-turtles
9 L. E$ m9 p. r3 q/ q7 A: f  create-turtles 100
3 q+ B( w; x+ n/ _  ask turtles [ setxy random-xcor random-ycor ]4 s4 Y6 h2 f6 @- R! f9 y) i, n; T& Z
end
5 R# c, \, ~3 I7 q( D& ^" H$ pto eat-grass
5 ]0 ~, t! I" l! J  ask turtles [8 Q  F& G6 ?4 z$ k9 G
    if pcolor = green [
0 j7 [$ _. v+ e0 _2 T9 |  ^      set pcolor black( T. g0 g: h, Z% C+ Q# B
      set energy (energy + 10)- M) a6 |% r9 L) E
      ]) K! Y) w3 f: O: y3 N* Z
    ifelse show-energy?+ M6 J2 k4 H1 b5 Q. O# y' ]( \
      [ set label energy ]& T6 r; g, ]  i0 J
      [ set label "" ]& q9 {0 h0 z/ ]& U
    ]
/ E* R/ k3 f0 vend
4 }6 F( Q4 J1 j  \7 l' e0 dto reproduce
. ^' F, H0 {6 I6 J  ask turtles [
$ x2 q7 r8 Y8 E: F    if energy > 50 [
% U5 z; o3 y0 a% s6 h* h5 R      set energy energy - 50
' V5 C, Y# A5 _& H$ N( e      hatch 1 [ set energy 50 ]" C, E0 V8 s1 P1 a* j3 V
      ]
, z! Q5 W* v; h9 h1 U0 I    ]& L% w9 B) q: P/ [
end9 P4 F% q  A$ U2 a7 w
to check-death. x0 T5 t$ Q, W! {
  ask turtles [
! C) _% |* V. F# L    if energy <= 0 [ die ]9 N+ M6 j9 V6 k0 U& p2 |
    ]
# Q0 \1 m& j# Z2 P7 F% send0 @3 t" c: `/ J% ~$ \& {+ p4 g
to regrow-grass
8 A4 y3 I& Y! G& B2 h6 u  ask patches [
4 b& s1 q2 n0 s& c% _    if random 100 < 3 [ set pcolor green ]
5 S  v% P& c* `& X2 P5 T    ]) O- o3 a* s4 d
end
) ]9 m; U3 n. x. u3 ^2 s9 dto do-plots& h  M$ O6 {+ A: g, T: M
  set-current-plot "Totals"
( U. w2 A: w( T" F" h1 M5 j9 L  set-current-plot-pen "turtles"3 i( T) \# H6 T6 u& Q/ B0 e
  plot count turtles- \' I. E8 |/ ~: v/ Q. `( s8 K
  set-current-plot-pen "grass"
& @( @! {) e0 f  plot count patches with [pcolor = green]4 w. I- [5 l& f  N( n& ?# Q
end1 R. \/ n5 Q  q6 F
可是运行时提示no such plot: "Totals"
) R. E. Y2 t! u& _- J5 jerror while observer running SET-CURRENT-PLOT4 P+ ~8 X" t' Y( x; R1 s' x
  called by procedure DO-PLOTS
5 {0 A3 y$ S) g2 M# H  z- `  called by procedure SETUP
8 D0 W) B" T6 |8 _! _. z! N3 {$ |  called by 按钮 'setup'
/ o+ J( D2 W- p5 m求大神解答啊
发表于 2013-5-29 00:25:38 | 显示全部楼层
no such plot: "Totals",就是说你的界面里没有叫做Totals的绘图框
发表于 2013-5-29 00:26:26 | 显示全部楼层
建一个叫做叫做Totals的绘图框就行了
 楼主| 发表于 2013-6-4 12:24:45 | 显示全部楼层
emlyn 发表于 2013-5-29 00:26 ' z8 C" N2 Z( L! Y, i
建一个叫做叫做Totals的绘图框就行了

" |1 g- }- c3 z哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2026-8-7 09:14 , Processed in 0.017696 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表