设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12673|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
/ D# O# o5 y5 b. N5 ^to setup
3 [! o# e2 M8 C  clear-all8 N+ M. ]6 S$ v$ e2 k! J  j
  setup-patches
, l& k- a6 v7 y2 f$ f! G  create-turtles 100
9 Z" z: G) W) I" o7 e  j  do-plots+ F) A9 C& c& e& {$ m2 [
  ask turtles [ setxy random-xcor random-ycor ]) {( N) s( L) q( e, i6 k8 [
end# y6 N; _% }7 r. k
to go
* p/ d2 x" n1 I) s  move-turtles; T; }5 _8 O5 n) B4 ^4 U+ p9 d: M7 W
  eat-grass
  M9 M% c: ^8 Z5 O: Z  reproduce+ G; f4 a& h2 u3 Z7 v
  check-death
" D/ v4 G6 G9 q9 d2 t! B7 ~; r  regrow-grass
- ~6 R6 U0 L3 P1 h8 N# Q  do-plots
. W: a' I: d3 ?+ c* I) b* lend% I* i% Z2 j6 J# O' c
to move-turtles/ ?( r, q. Q9 Q! q4 ~
  ask turtles [5 E0 }" Q' P& Z& ^0 ^9 q2 F0 t/ E
    right random 3602 ~9 _4 v1 L) a$ G: n' W- [
    forward 1
' L6 r- \# I; A) d- {  v8 N7 G    set energy energy - 12 F0 R) W; B& J
    ]- w& ]: [5 q# M, k' ?' D' W0 _
end. X9 @/ T/ l  `% ~3 a2 l7 M
to setup-patches# t2 f2 `+ }# K) F7 r
  ask patches [ set pcolor green ]
9 R5 z* _* ~. Q: }end2 h1 \$ [7 a7 ?& l4 x0 p
to setup-turtles5 P: }0 y1 I$ o: n% A! T  M2 ^
  create-turtles 100
$ L  w! R6 \1 `: i; U  ask turtles [ setxy random-xcor random-ycor ]
/ W! a) W+ n2 ]0 f+ Lend
7 v9 n" E' @) U4 a0 rto eat-grass
( o! U2 V  \* D* t  ask turtles [! c3 U; n! G  ?
    if pcolor = green [  ?. `) z$ u* h: C$ w2 q
      set pcolor black
5 U9 M, G' H( x      set energy (energy + 10)
8 [2 ]* ]+ J0 H* m+ q9 n* J& H5 A' a      ]- z3 }' O) p& W! N
    ifelse show-energy?
5 L: w0 [  j. L" C" B8 U+ n0 K3 p, j      [ set label energy ]4 V! a' E0 y$ ^' g& v* X% J4 }3 c
      [ set label "" ]
" Z1 `+ s8 Q& X; `    ]2 A& }* ~! V. Z
end
  A1 w/ ~  P6 H! L) Xto reproduce- ~- f+ C: V9 O7 ]0 r+ A4 @* O
  ask turtles [. q  [* m* B; J# y7 {3 s
    if energy > 50 [
0 H9 v% U: j$ B# d      set energy energy - 50
, d$ }+ v4 B* P% l( M      hatch 1 [ set energy 50 ]1 C  t, f% F% ]' Z$ B$ E
      ]
8 J& {1 z! ^) D4 q; t5 N+ I; M    ]" x0 A3 t' G" [  S$ T0 {0 r
end/ b) V# [2 N) D, }# K
to check-death
, {5 y7 L' I% g' U  \  ask turtles [
! R8 ^5 U9 C. r( D& E    if energy <= 0 [ die ]
/ y/ @+ c; r" |    ]8 l$ A8 {4 L1 f8 y8 d' [) d
end9 i* ~7 G! E% j" T. a
to regrow-grass8 z+ J5 }% w4 W
  ask patches [
& O0 @1 v( X" T    if random 100 < 3 [ set pcolor green ]
: y/ h5 r: ~. r3 j/ Q" \. w    ]5 T" B; y  t: e$ J+ P* r
end
( Z* a3 }% C1 L$ ?to do-plots
( F/ p+ n/ @2 L2 T' J5 d6 Q4 w  set-current-plot "Totals"5 w# Y' W% b& q; C5 M
  set-current-plot-pen "turtles"7 {( {# Q$ f# M$ H3 q  p* R
  plot count turtles  J  V7 B5 K/ G' E% u0 s- T" g* _
  set-current-plot-pen "grass", k' C5 ], L8 k2 d  t
  plot count patches with [pcolor = green]" E9 k: J& [/ Z0 D$ |9 s
end/ N$ D1 x- p% J; K" Q
可是运行时提示no such plot: "Totals"% ~0 g/ O3 A; h
error while observer running SET-CURRENT-PLOT
; h+ H! B( x$ ^+ O0 E5 o1 l  called by procedure DO-PLOTS
% U- ?  y9 f! v5 q* q  called by procedure SETUP
1 k4 A: z: L0 e8 D$ p& S4 |  called by 按钮 'setup'9 m" {4 ?. C/ Z% A( |9 r" F+ b6 ?" ^
求大神解答啊
发表于 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 + D! R: A# {- {, ~9 u
建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-9-10 21:03 , Processed in 0.016494 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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