设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12494|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]$ C* B0 V! U7 a! S
to setup; u" w+ M, U& w4 R
  clear-all
5 ]" o- k" |* I! o* V  setup-patches
: ]4 s/ q3 ]( F9 u  create-turtles 100
& T0 t" h* _' z+ Z  do-plots. s3 P% ~5 D% L! c6 e/ `
  ask turtles [ setxy random-xcor random-ycor ]* {- @  n/ a9 K  I
end' M/ C& ~8 d6 g  Z0 t
to go; V$ m4 Q, r. s' ^7 z% g
  move-turtles. z- ], u1 c" y; n" I1 i* n! h
  eat-grass
. b' U7 p/ {3 g; C' S0 G  i% z) J  reproduce( E6 g/ M, m; h: G
  check-death
6 R9 T: p/ L9 N+ S  regrow-grass
( ?! G5 E" S2 Y  I7 L4 n2 k7 m  do-plots8 o3 H( i7 p. ]7 B( t- a* |
end6 \. u: o9 E! k8 i1 t/ t+ Q3 N
to move-turtles; _& N; P# p, w% k$ L
  ask turtles [
6 R/ G# @8 s2 L; a    right random 360
. x$ D  ?  s, P" X, r( @! j0 ]    forward 1
$ R' L' v: ~' M+ L    set energy energy - 1) k3 Z8 F& |" e( r
    ]
5 P% o; U" m" `" Tend
! k. _) M2 m$ ]9 ?& e( dto setup-patches
! M# R) Q8 U8 i  g0 |0 U3 ~  ask patches [ set pcolor green ]
6 _; ^& J3 G5 D0 Vend
# }8 H; M5 ^: x  xto setup-turtles
9 u* X) X7 y* l; O4 D  create-turtles 100# m7 a8 Z* \1 F# r3 L
  ask turtles [ setxy random-xcor random-ycor ]4 L0 i4 O4 E6 E/ l
end
8 V$ S. {4 c: q; uto eat-grass; x+ @. u$ {: U, E7 }
  ask turtles [
' m1 O5 ?8 @0 g/ B1 x) s2 X    if pcolor = green [
* h1 C" L1 k3 J# m" z8 p      set pcolor black
- j  x: i* @$ S# D& u6 B      set energy (energy + 10)
6 P3 I# S" x& n+ K' I& s4 g" O1 ]      ]. A" x( k6 y2 s7 Y3 k
    ifelse show-energy?
. }9 T" g: i1 M# G4 M, u! d      [ set label energy ]
  S, P  A+ B6 m& d7 V( y3 P      [ set label "" ]
& x5 ^( L  G0 w2 |    ]
( j4 H9 R1 N) D4 @2 D8 \end; Z7 |- p  f4 H  r
to reproduce
7 B4 L4 t1 A- X) N. \  ask turtles [; r+ _- P) W* ~- f4 N, b
    if energy > 50 [
( V. X: o( G4 ^0 l" m% p/ L$ o0 G      set energy energy - 50" X( p- c6 ~3 u) m
      hatch 1 [ set energy 50 ]3 {' ?6 v0 b' `  V( r) s
      ]
! l! x' K/ D9 e1 R- h    ]
& ~6 ?7 S" e2 ^4 J* s" Rend
. ~7 W4 P0 H9 eto check-death  {. Y% l& b3 K0 d6 J6 Q% k/ [
  ask turtles [
6 i0 t( F) F- Y- |( q    if energy <= 0 [ die ]* F8 w3 ^: K0 w" B6 s
    ]: ~. ]3 d1 P4 c" f5 F
end
6 C; Y+ I# q! S% B3 {6 ?  bto regrow-grass# l$ ?" ^$ }0 G/ {  r
  ask patches [
4 |- L* ?' K& z. Y' D    if random 100 < 3 [ set pcolor green ]
2 o2 T0 O! I1 _. [4 y8 @! [% o7 g    ]0 J2 I5 r7 p. s4 B( N
end" X* L3 M0 y* D* {$ A9 U/ _( ?
to do-plots
# N' z' a3 {# I$ X  set-current-plot "Totals"
$ \- P* }8 l3 T* Z9 C" P  set-current-plot-pen "turtles"
- V' y1 ]: W2 R! I" h) z& p2 R7 j  plot count turtles( G/ ]% l" N! J6 C8 y7 F
  set-current-plot-pen "grass"
8 G, u7 _& {1 P1 L3 H. _. |  plot count patches with [pcolor = green]* t. k. _( T2 {, t4 O7 l
end
) B) J' f" J& I5 ]. Y* u可是运行时提示no such plot: "Totals"
6 [. L' m2 A. N+ B- lerror while observer running SET-CURRENT-PLOT
8 P: a( E) M1 N9 T) t  called by procedure DO-PLOTS  c' v! H# p0 o
  called by procedure SETUP
6 Y2 Y' V7 K5 o! V7 ?  called by 按钮 'setup'  V/ Y& l9 B( E2 ]2 J- ]
求大神解答啊
发表于 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
9 O$ w/ ?/ B6 _0 i& A; V. v7 ]0 }建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-8-27 04:17 , Processed in 8.375986 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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