设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12683|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]3 t6 N3 C* l% c5 d; Z: Q# ?4 i
to setup2 X2 q) @  d# P; U$ x* h9 _% F% y
  clear-all" |# V- r. N4 H2 @  p
  setup-patches6 \7 ~! x8 B0 y9 {
  create-turtles 100& [% O9 {( n  f
  do-plots
2 e% X; _( v% P  ask turtles [ setxy random-xcor random-ycor ]! {4 T7 }- J( m/ m) C8 E# m3 l( o" C
end9 \7 [* B: E6 M9 Y% |4 N' t8 e
to go
& j6 W+ ?( C3 G9 j5 E  move-turtles
2 E$ u2 ]5 ?0 m# T  eat-grass
# Z  `; q; g/ v, Y# }0 A- W( t  reproduce) e: w. R0 y# f) i0 Y$ ?8 @
  check-death
# f% v+ Z6 n: Q8 b6 G  regrow-grass
8 N( F" {3 N" g, E  do-plots3 |  s& [, d9 S1 |! c
end
# e+ ^4 ~6 B2 @6 f: jto move-turtles# }2 z! I  s7 M$ W
  ask turtles [
5 z+ A0 T5 [( c; @' Q% t    right random 360
$ v* |* J& g* f; t    forward 1
) L$ `' g; `! w; P    set energy energy - 1
8 n1 h+ `, l# T9 D6 s    ]
! ~+ V: W& d1 n: e4 zend
3 T7 _) W* C  B$ q) W' t: Yto setup-patches! y8 H- X* t  [! j* o  }! k6 j0 _
  ask patches [ set pcolor green ]
+ Q. L; o) L2 r5 H: rend& y. f! a6 t' F3 M; F& _& d6 ~, [& M
to setup-turtles4 ^$ W$ @/ m& z
  create-turtles 100  R9 j! M3 v4 p4 F: B! X
  ask turtles [ setxy random-xcor random-ycor ]) T7 t& V9 n# F3 R$ |7 G+ V3 B2 |
end' s7 W- T/ x( ~; B: w" h" G2 _; |
to eat-grass
' s( h6 u$ E9 [  ask turtles [* i! J0 _' R" h- [
    if pcolor = green [- M0 [! L6 a  O# F" O) R
      set pcolor black5 Z3 i0 G" G2 `& d6 C* {! m& x
      set energy (energy + 10)
* P" D+ k$ I" X6 X      ]: i' C& y- k. _. D: p
    ifelse show-energy?
: k. d! g& a, X( A. a6 }% z; H      [ set label energy ]
6 {9 E- [% ]: Y) F9 d  p1 a      [ set label "" ]
" R% g9 K7 o7 P3 X    ]' Z- t2 v( b% F/ ~/ e
end
  s3 Z& E- a9 Q+ ~6 A$ B% [to reproduce
* E# @% J8 h+ G4 {* K% ?  ask turtles [
  C  l& ]- C& c- b, I. q* N: E    if energy > 50 [
4 S  H7 ?8 N, e; m      set energy energy - 50
0 M, e8 c! [3 E5 g" {      hatch 1 [ set energy 50 ]/ x$ T; o; }3 ], P% n3 A
      ]
1 j1 _% L- F/ e7 U# M- p3 |    ]
8 e7 ]/ O' _# T- Qend
3 l3 r) u9 d* ?to check-death! I( s/ ?$ g, u5 {2 b7 t* G4 O# w0 R3 P
  ask turtles [& X2 L. ~0 d" y. r: q8 Y
    if energy <= 0 [ die ]
) A4 `' ^' E) Y8 c+ j    ]8 Y5 i0 A" L! t" t( n: E
end
" d9 Q. ~  v- Gto regrow-grass# ~' T/ z' c& p  t! ?: Y2 _' z3 s) {& d
  ask patches [) u, U* z$ T4 G; C! M+ k7 M) j7 M0 }
    if random 100 < 3 [ set pcolor green ]
# @$ h( a% M# z) l/ b    ]: f0 {, Y4 t4 Z; R
end+ e+ V5 H& Q8 n  _8 h
to do-plots* j0 Y) G, \# G6 D. ^
  set-current-plot "Totals"
" G2 X& M, _# ^# J) `$ b  set-current-plot-pen "turtles"8 T1 W1 z  {. |0 l7 t. V0 e. Y3 @$ `
  plot count turtles
. W1 z7 H: e+ o9 {, B  set-current-plot-pen "grass"7 D- @, G0 G3 @& F. e; ]( c
  plot count patches with [pcolor = green]1 ~! g) y, L4 @+ H! L; @
end
' ^& |5 d' G% o$ _6 ]可是运行时提示no such plot: "Totals"
3 L) n- p. Z& z6 }- zerror while observer running SET-CURRENT-PLOT# H8 W' l  o* P
  called by procedure DO-PLOTS
6 |3 g) b5 p) R) I; g- |' a% p2 h0 R  called by procedure SETUP" B# t1 V! x7 W( _
  called by 按钮 'setup': S: T1 F/ s, q+ K* e) J* x
求大神解答啊
发表于 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
) b% z0 d6 s5 B* c9 ]4 X- A6 |" I建一个叫做叫做Totals的绘图框就行了
9 j) R& r8 F' _$ [- ^
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-9-11 09:35 , Processed in 0.020319 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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