设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9337|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]. w! f$ q4 A2 X6 ]5 Q  R
to setup
0 G' m  J2 t1 A' I  clear-all' F4 e  w$ W3 N! \/ e; |: s7 W4 Q
  setup-patches6 q: B/ ^2 W% d5 C6 ?, I6 H
  create-turtles 100
1 t& g+ b: e1 r  do-plots
- l6 Z  O+ x# h4 ]* ^1 M. @  ask turtles [ setxy random-xcor random-ycor ]
! t) ]" t/ G% I9 }) m" cend
+ s7 d( G/ ^$ j2 O* |  Eto go2 Q4 e6 \: c6 R  A/ o7 H0 \
  move-turtles
8 g+ k9 }$ ^( q  eat-grass3 l8 D( X! J' _1 |& ^9 d& N
  reproduce- }4 S1 D" p# L/ p1 x, B
  check-death
4 z5 |* o$ P" E$ @( Y0 l  f  regrow-grass+ E! d" t6 A: R( Y, q
  do-plots. t7 @! j2 x! K* [
end+ q; M' _; u/ h# S6 o
to move-turtles
2 W( W- A8 p+ T  ask turtles [
5 D- \2 k9 @8 V& g    right random 360
6 o  h$ ~# ^! Y* Q( y  f8 V    forward 1" y8 J9 r- g/ q9 j2 k9 Y/ K6 N
    set energy energy - 1) f2 G- o) o$ ^, b
    ]
2 O0 r$ ]' r' J, l/ |9 zend
$ c6 C- p, c) Vto setup-patches
$ v: Z& j9 \  L+ D4 O3 d; z  ask patches [ set pcolor green ]
# c& ^+ B/ Q* v' @% i; iend
; e0 a3 N5 `9 z. xto setup-turtles! O% D% a0 M' X
  create-turtles 100
/ n# g8 q0 T. ?" Z+ C9 t6 T/ h  ask turtles [ setxy random-xcor random-ycor ]
( b% E9 y: V2 R! G6 `( ~end
0 B) k2 a0 S6 k1 Xto eat-grass9 h5 L' _, [9 O& o
  ask turtles [/ O& O; k: j/ E& `' O! p
    if pcolor = green [  o, H8 j- K. k
      set pcolor black
7 i9 z2 \3 P3 f, f4 M- t/ Q7 {! I      set energy (energy + 10)
8 U% ~( {' G& a7 g      ]
6 Z# D& Z" Y; M( s8 w: ^    ifelse show-energy?2 y4 o( M' x& [% W" l: r6 \' `& Y" s
      [ set label energy ]* |0 y* e' x+ _6 I6 e2 X8 L' a
      [ set label "" ]
; ?' r8 ]( {9 j; J    ]
5 z6 ]( m; f9 i3 iend' B, u( b, N; x+ k5 m
to reproduce
/ e7 l6 S! b( J  ask turtles [
7 ^2 D; U9 P* G( C+ U8 o    if energy > 50 [
7 v$ p6 G( c1 V: O5 D( Z      set energy energy - 503 U2 v, N5 [# D$ S0 }& D5 Q- Y- H
      hatch 1 [ set energy 50 ]# j4 l( @/ P) b: m5 ?& q( o! S& l
      ]5 g- W, p4 F" y0 x5 {) r9 B3 B
    ]' M) Y# H+ _4 w& z
end1 _  N+ Q, W; S/ ]$ t
to check-death7 {' z# n$ Z7 ~
  ask turtles [
7 {8 O2 g5 |* N6 n    if energy <= 0 [ die ]
! x% g% t( Z0 [; G8 ~    ]
2 e% `1 I- b$ J& |end5 Z( Y9 R0 F2 q! ]
to regrow-grass
! x' L* u3 S. P1 e/ P$ z) v9 @  ask patches [
  T" I* y" B* a* k    if random 100 < 3 [ set pcolor green ]4 f) U- l  g( g5 a- g' M* s" T
    ]
  Y$ o5 b& W* Lend9 G8 f0 J4 d; I
to do-plots1 I; F, d1 I2 [+ f6 r
  set-current-plot "Totals"' M. y* Z. ~9 U
  set-current-plot-pen "turtles"% G& r% o1 T' x
  plot count turtles$ u- k$ y$ k  H1 Z5 h
  set-current-plot-pen "grass"
3 ^! ^3 c9 n5 ?; ]  plot count patches with [pcolor = green]) w5 R3 x; l  J. p, t7 Y
end9 b) ?( w6 M7 j' y0 X1 \
可是运行时提示no such plot: "Totals"
, L3 |& R: L' v- ^error while observer running SET-CURRENT-PLOT# e$ H! M+ b+ g# r% w
  called by procedure DO-PLOTS% u$ y# n6 Z) J) r4 g8 u
  called by procedure SETUP
6 m' J6 g) x4 _0 c: h& K% f  called by 按钮 'setup'0 V0 `  e8 [% v% N. ~2 @
求大神解答啊
发表于 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 % W* r9 r& E" Z$ t7 r* k
建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2025-12-9 06:17 , Processed in 0.020400 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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