设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10114|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
4 a  L, }! U5 ]. u( rto setup, s. R3 N6 B. w( M- O: H
  clear-all
& Z5 y- x+ w' F0 Z% P  setup-patches" Z8 c$ Y7 _' w, k1 V. X* r
  create-turtles 100" A) a4 |3 l6 _/ O, u4 j/ x
  do-plots  f6 q5 p8 I8 |" q# I( q0 `5 k9 a
  ask turtles [ setxy random-xcor random-ycor ]
1 _& x& e  E7 h) d9 @2 n. u( Nend# w6 a6 [3 r4 I- }6 m: M% P
to go; `8 z: E* q: [- H( g  G
  move-turtles$ u9 w1 }9 s$ s( i, V$ w! E
  eat-grass7 @6 M/ g. @% ~5 _  T3 r% D
  reproduce
7 A$ }' M+ q0 C& C8 A, n4 k" n  check-death" N6 P# W. N6 D  S+ v' j- ^
  regrow-grass
, [: ]0 _% @* [  do-plots
1 q, B* p# s$ q! ?+ h) m7 ~; ]- Aend
8 a0 f9 ^9 |1 \/ P# p' bto move-turtles
1 S$ h  j$ Y2 B: |0 j  ask turtles [
$ T0 v3 M- D# j; p, }/ W% S9 `    right random 3602 M4 e" M1 U  A
    forward 1
9 [1 i9 w7 ?7 _+ y    set energy energy - 1' }. B" r$ }" v( u* N6 Z, x
    ]
8 j6 }: s* s$ a( Y& zend) V+ i6 \5 p+ h6 _
to setup-patches/ `6 I4 m: @, _" c: j
  ask patches [ set pcolor green ]+ o1 I4 ^+ |$ Y2 ?/ O! p
end) l  X. V. l  H& G- D2 g0 S
to setup-turtles
" U2 H4 n' K# b5 ]" L* s  create-turtles 1002 C  P) b/ e) U7 @  Y8 z0 p
  ask turtles [ setxy random-xcor random-ycor ]( o  I* o! G, M/ {& l
end% h: P+ g4 k% J! n7 {2 ~/ p6 g
to eat-grass, a4 J: V* q" p* F
  ask turtles [6 P( a' X: d- n; c" h7 K( J/ B
    if pcolor = green [3 G! K  J2 G$ M: w/ N
      set pcolor black- v0 e/ S9 Y5 k& ]) C2 W) x* C' x
      set energy (energy + 10)& D, n7 d/ P0 v. U( r. ?
      ]
3 V* W# G* w2 [0 W' [% T    ifelse show-energy?$ r7 x1 T/ y! _8 a! j9 A5 f6 K# l5 l
      [ set label energy ]
# }8 w. r+ _7 B0 p4 ?* L      [ set label "" ]
/ }0 `1 d" w( o+ [8 F! u    ]
" Q4 K5 q* `. ^2 N9 Yend: H, T9 B1 E3 q$ W; s
to reproduce
+ |0 E* _6 B( J  ask turtles [
) W6 h  O6 r6 B% |( o    if energy > 50 [
4 y0 [' ?+ O) n5 l/ l      set energy energy - 50
. v( H8 J7 T' ~. v/ p& {      hatch 1 [ set energy 50 ]  `' V" q6 I$ G* l
      ]
- e& i% [# j7 a4 q0 k    ], g# R  g0 {0 ^$ j
end3 O! Y5 D: \) X' i0 M; x2 k
to check-death
6 I" D: Q9 e6 `) M9 d6 P  ask turtles [; y9 [. F6 e5 t! H$ [& G9 J8 |) ?! e
    if energy <= 0 [ die ]
* @4 [7 H) L& f& p  {( z( F    ]. Y- S( x: Q$ x5 t
end$ Y3 O) h2 U; E
to regrow-grass
' d3 Y3 E! w* }* e% }  ask patches [8 [& H6 w# R7 p9 J6 U( n5 I
    if random 100 < 3 [ set pcolor green ]
' F2 Z' l& `: I+ k8 @. g- v    ]+ G8 o3 E2 ]+ {$ `2 S$ c
end6 ]0 ~4 ?! n2 U' E2 ^3 Q, f; D
to do-plots  p" r7 c) q" R% m+ X: r
  set-current-plot "Totals"
1 ?3 ^) U5 K' B$ b3 q8 N: y" r  set-current-plot-pen "turtles"
! E1 ]- j+ |" D; _  plot count turtles* _0 n/ U" C, |# d* y. P% J
  set-current-plot-pen "grass"
$ ~4 i: o6 t$ a# T6 j) j2 K& N  plot count patches with [pcolor = green]; ~6 K  t7 t/ m& H" {
end# t; [- [# U; o/ n! M2 _% u
可是运行时提示no such plot: "Totals"
- R$ {& d5 C$ a& B' ]error while observer running SET-CURRENT-PLOT& k2 x9 u  V. y! k# h, ?
  called by procedure DO-PLOTS: ~: H2 c& ?7 l3 K
  called by procedure SETUP$ [8 z. J% J+ t* I! c
  called by 按钮 'setup'
, X/ X- v/ B! n4 p+ G求大神解答啊
发表于 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
" \5 e! N2 L7 a9 C# }建一个叫做叫做Totals的绘图框就行了
6 _$ r+ |4 }* c
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-2-14 07:56 , Processed in 0.020265 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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