设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10921|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]6 j, ~; c) L" f5 M* D, ?
to setup; p5 T. Y# m! p1 O5 A$ ^8 ?
  clear-all
4 R) P* r  a. l) N+ V  L8 Q  setup-patches
4 Q/ u8 f. l; t( \" P  create-turtles 100
: V8 k1 P: |+ x9 Q  do-plots! f2 D: {+ v) N) ?7 Z' Y, Y# }+ [
  ask turtles [ setxy random-xcor random-ycor ]( J6 L- J% e- k
end, i* o* P' H2 c: ~5 n
to go
6 Z( l+ W$ l- z5 f% o  move-turtles
1 E  t& q/ V3 |/ h  eat-grass6 U# Y. D& e. k* T
  reproduce
  X  a" `% p( W0 J5 j- G( q, Y' ~$ n  check-death
& p9 F3 @# Q, h" b9 H9 A. @8 N/ T  regrow-grass  \" {! y9 P7 _" \! |8 _7 [# L: O) a
  do-plots5 ?+ M* x6 \6 d) B- z
end4 Y  c6 a1 O5 S3 t
to move-turtles8 T! p0 }% X3 b6 \% d! c* J& k
  ask turtles [
6 i2 c8 S/ |/ t: D" Z* a    right random 360* d% j+ X4 Y& h( \
    forward 1
% C  U; [4 ~7 v8 i$ V9 _    set energy energy - 1  A/ p+ A+ u& @. W$ |' B  U4 c
    ]
+ |: ]& z7 w0 Q1 oend
) ]0 T. G5 `8 j& q" @to setup-patches. B; ^1 t% n; b* e
  ask patches [ set pcolor green ]3 }% t) c; J3 _  a
end" K) X* O' t& @  P  Q# ]. [
to setup-turtles
) |: w+ e' q+ Q% y$ Q  create-turtles 1003 @; y; Z8 n) g% ^1 @; D
  ask turtles [ setxy random-xcor random-ycor ]; A. x$ ~( |# }+ _8 \! o) I
end  d4 ?; F: N7 @' E. R# e- s/ U
to eat-grass
& ?" x  C- H( X, P* {  ask turtles [
& r' u; _. w) x1 x0 |) D2 p    if pcolor = green [
1 z! c$ l6 G9 |% P3 Y1 s9 F      set pcolor black
1 V9 K4 c  f( z      set energy (energy + 10)
  r3 {! C1 i# l; |: p5 a' b9 A      ]
2 F6 F+ ^& @7 H( L: ]    ifelse show-energy?+ a  s# P5 g1 p3 l; a- i4 E& e0 ]
      [ set label energy ]9 c3 t8 i; P% N/ e& V4 U$ Z
      [ set label "" ]$ s: q  p! P0 [3 F7 ?) c
    ]2 q% O1 l4 @+ z2 n
end* e6 ?5 A! E' D
to reproduce+ S/ C& d( r1 i8 g
  ask turtles [5 `2 W# E" T% T0 N* x  l1 h# b
    if energy > 50 [3 j- g/ B: |0 a4 H
      set energy energy - 50
6 j( f' {1 q8 U      hatch 1 [ set energy 50 ]! e5 v( e0 }8 e7 b4 [
      ]% K! _6 B0 P2 F! q( e- Z* f/ i
    ]" }  k3 Y& ^8 R
end4 b% Z4 F' Q8 G" ^) K
to check-death
  O9 ^  W& h  T# Z. x8 T) {  ask turtles [
; g7 `  P; W" S  c, i. C, s5 O    if energy <= 0 [ die ]
& i% c' F7 ?' ~( |5 E% ^    ]' c' i2 E7 h; P
end
3 \) L2 T3 k+ d( P0 [to regrow-grass9 B" p& Q" R1 a% r* f
  ask patches [3 \( B, h: P+ V( A1 R
    if random 100 < 3 [ set pcolor green ]
4 _6 ~9 s$ K4 l9 U* _  t* x9 b$ q    ]
: [* O% d( W& ~7 k. S. _' q5 _end9 Z$ G7 m, B3 P
to do-plots
# V3 ~2 }; Z$ E% a6 I) W7 \  set-current-plot "Totals"
+ U* Z3 Q1 i0 D* G$ h4 }  set-current-plot-pen "turtles"
+ W% ?& u/ I2 \8 s# X) c  plot count turtles
& @$ y" U* R( w7 s  set-current-plot-pen "grass"
& a' Z1 l0 B/ i) O: u. k7 l8 C  plot count patches with [pcolor = green]7 ~; O3 z' C( A/ Z; U% x1 q
end
' M' K# e) h1 s* i1 z可是运行时提示no such plot: "Totals"
+ Z) @9 S9 V: Cerror while observer running SET-CURRENT-PLOT2 \3 B- |6 S  w, j# F
  called by procedure DO-PLOTS
6 {/ K- Y8 O' J2 `$ y3 u2 q: w  called by procedure SETUP0 K% D# q: q. \& a# l5 a# P
  called by 按钮 'setup'8 E; t. y2 {# C0 w, |* T
求大神解答啊
发表于 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 . Y! A# q6 K4 V) G7 F
建一个叫做叫做Totals的绘图框就行了
5 R  Q8 S: ]( l2 S! k
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-4-20 19:41 , Processed in 0.022490 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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