设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11688|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy], t+ y% t8 x0 `
to setup& J' ?6 o) }( G4 b2 K
  clear-all
; ~% ~0 d, d- O0 n& H  setup-patches% ^+ X7 g3 `+ w- v; B7 f/ Y) j
  create-turtles 100
) ^7 k$ s& ^8 A5 Z+ T7 _  do-plots) K+ h+ i/ ~) B; B( B8 \
  ask turtles [ setxy random-xcor random-ycor ]$ G2 B8 U) E/ S. j! b, H
end
3 c- i& K" K9 B" f; hto go1 ~1 m! X, p$ H/ K
  move-turtles, p* z, b; ]: P; ^* \0 h, B+ J9 i
  eat-grass
7 \8 E% T  ^+ ~2 [0 Q8 L1 e0 i  reproduce% l( G, A( m6 |& ~8 a- P
  check-death
' n5 f3 V5 ^: o- n  regrow-grass8 F, p! o; v% S4 B* P  t5 ]
  do-plots8 f5 f/ l6 Z6 t+ h& Z: P
end% c  W& A* z1 Q4 J9 F/ Y
to move-turtles
! {2 i$ e+ K9 r- w9 ~  ask turtles [
/ [5 b! `; Z4 M9 v9 {9 }    right random 3604 T; |$ M4 g' _6 R& s# f' O
    forward 1
6 v6 O, {- B8 j3 k4 L    set energy energy - 1
" m. m) S& y$ l- j' a' I    ]/ Y1 m- y4 T/ ]7 _/ E! [; o
end9 P' u6 z( j- a  x& y) [. ?
to setup-patches
3 v% g6 C" y5 V/ k6 y' a  ask patches [ set pcolor green ]
! z( w9 D. q; K( F# nend, _  y. S* C/ D9 O2 W5 h
to setup-turtles+ @! p) K) n1 I" W5 G
  create-turtles 1003 E0 O- ~4 g) k: y2 Y2 @: a$ t
  ask turtles [ setxy random-xcor random-ycor ]
7 ~6 P/ _1 e: S4 L) G7 l1 W( mend
  @- X* K/ H0 }" i) D; Bto eat-grass+ Q1 j/ u" U! z9 O$ R% M
  ask turtles [
+ A$ P4 V3 \* Z, t% k$ Z9 b    if pcolor = green [
" C! O* b" k& q; A# i      set pcolor black
! V; ^. _  ]! r8 G  f1 \      set energy (energy + 10)
# ?) p7 Q. P$ A4 n      ]
8 E+ P5 l* W- U$ o' _& K    ifelse show-energy?4 h! f+ ?2 b5 O/ i8 d( b( u
      [ set label energy ]* T* c- R+ w3 E+ |  H. w1 i
      [ set label "" ]
, E% y' r& o) c2 j    ]
2 |1 c4 R9 Y3 `end
% a' s2 Z& J. j+ W' K/ b( _( Wto reproduce2 }/ A* T/ H6 h4 f
  ask turtles [3 a+ R% d+ _: J0 q6 \8 ~
    if energy > 50 [/ ]4 ?+ M8 p, [* _
      set energy energy - 50) O# H& a( H- e( z" |
      hatch 1 [ set energy 50 ]
& k3 p$ E" e. w      ]
9 y2 ]3 R& L2 d. h( O4 t2 s    ]
% f' F. M$ H7 g) F3 d/ F: vend
" Z& N5 y$ y9 ?9 K4 r, g  x1 H3 y6 Hto check-death( B4 `' r1 D; S. e
  ask turtles [
, Q' U  L& E$ V+ O* L- N: V9 A- t    if energy <= 0 [ die ]
3 O$ a4 h% [4 d4 l* F    ]
8 V6 G+ E7 I1 J' H; z% Dend8 Z' H4 e" o* l* b
to regrow-grass
" e+ H8 z( _. o1 u4 L, B! D0 i  ask patches [
  T1 n8 ^# I! @- j    if random 100 < 3 [ set pcolor green ]7 h6 |2 V% R; S  Q! _
    ]/ g* |- ?& Z* P5 l$ A7 T
end
5 x( Q0 q6 _2 }/ k: Sto do-plots7 D  N, [$ O# X3 H3 n: P
  set-current-plot "Totals"$ Z3 |0 n  l! E( x& f* k) ?
  set-current-plot-pen "turtles"
7 z3 J+ O/ H& o* `) K  plot count turtles
2 d8 Q: I* D% V  set-current-plot-pen "grass"
4 e: b/ z" M0 j) m) P  plot count patches with [pcolor = green]
( \% L* n0 E3 y, hend. b% }0 x3 C+ K. p  s
可是运行时提示no such plot: "Totals"7 K9 p& [7 T$ u8 _' ^5 w+ n) m! Q
error while observer running SET-CURRENT-PLOT4 d( G. X) G# t7 K
  called by procedure DO-PLOTS% L% i( p+ h4 O: o6 @8 V
  called by procedure SETUP: c* \/ @" _3 t) B% ~4 U5 k
  called by 按钮 'setup'6 B" v0 A6 }2 C1 k* a
求大神解答啊
发表于 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
  T& _0 k, c8 b; ?8 Z* _9 ]2 A建一个叫做叫做Totals的绘图框就行了
# I' t. A, }" H
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-19 17:13 , Processed in 0.016333 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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