设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 5980|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]4 F- L, o" N/ H  ~
to setup
* l7 f) A' _0 M4 H4 s! p  clear-all( ?* k- }; b- {; G7 h
  setup-patches0 T: w6 _' k3 L; r$ g
  create-turtles 100
& ^( T) _- A2 d5 V  do-plots" Y! t, j. [! R$ P2 L
  ask turtles [ setxy random-xcor random-ycor ]1 c- g2 d3 {4 o4 q0 A; R
end% V+ ^: K' H. q: d$ Z* ]# y% @
to go
& K0 q6 `9 Q* d) t, y7 o  move-turtles, G8 M% ?8 |1 C& Y0 N9 a- V  ~
  eat-grass, N* k5 r8 u: k$ L* j/ r
  reproduce
% i. s1 k. a" }; Q& x5 ^2 v* t  check-death/ N4 w/ @' o* g6 _. ^8 u+ [
  regrow-grass7 i% C' l5 o( R
  do-plots
1 Z, B. j7 _, w% f3 L& s- b3 b! Kend7 M; C$ w9 _" ^! D2 h  C5 D
to move-turtles" _1 F' k+ j4 n5 [( E
  ask turtles [
3 M; l2 ^$ b& E! L    right random 360
9 @" n1 A$ {! P! d, A7 y    forward 1
* v$ J) t0 c, R( Y' ?3 n8 {    set energy energy - 1
# y; c# m1 M4 P& G& }    ]9 W0 f: ~8 x! ^5 L2 {) d3 s: z/ H6 U
end
; |1 E, G  V( Mto setup-patches; \* q) b+ }1 E4 q# @$ y
  ask patches [ set pcolor green ]. e# U' n% @: ?, f7 A
end
( R$ L& w; R, J/ I" W% Hto setup-turtles
) F% `; ]/ a2 e6 b2 n+ i: A0 F  create-turtles 1009 s* {- p( D% U
  ask turtles [ setxy random-xcor random-ycor ]
5 W6 b7 t5 i2 h  d% u+ |end
. Q1 t. T) J2 n! r% Z5 a. ~, Tto eat-grass, x# _+ C9 ~1 w
  ask turtles [5 \% P/ P3 h# _3 e0 f* u8 S, r! m' R
    if pcolor = green [
* p0 @; z/ \% m. W      set pcolor black
5 {* O$ |4 [) H& e# n      set energy (energy + 10)' [8 v- J( U( F* k( Y
      ]
4 R# A! o1 z# R6 Z    ifelse show-energy?
0 t, r# ~! B& q5 q+ d7 f      [ set label energy ]
4 \) x* [0 f  W$ N9 t" D/ H. M      [ set label "" ]. F! U; k4 y" h$ E
    ]
' S" J, i" Q% L% v9 mend0 t( A& w3 ~7 c5 D% _5 J- t
to reproduce
( X/ w- ?' A! T; v! `  ask turtles [8 w0 O- ~1 |" W. r' W/ r
    if energy > 50 [! E; z: \9 M' i: E1 V
      set energy energy - 50) g+ ~' x; [* f. T1 W5 {
      hatch 1 [ set energy 50 ]0 d: ?: A4 r5 n7 {5 B& J
      ]
; X; o, X) H4 `/ w1 }$ \/ w    ]* m' ^2 F+ C, P* u3 {
end
8 n6 ~5 X5 b5 |( ^to check-death2 W& @! ], ^. ^$ _( q
  ask turtles [
! M( H; w  d4 O' r, x8 U: L    if energy <= 0 [ die ]
& S4 V' D, l& `' i    ]
+ N( B" t/ x4 Wend
3 C/ F* Z( a! d6 {2 q) {1 zto regrow-grass
# u2 s( q; D0 E9 h3 L* G  ask patches [
% p7 C0 t! s; ^$ u6 k    if random 100 < 3 [ set pcolor green ]
, W( n, C9 B! T$ b) k, g9 H3 J, ]    ]
8 r* ^; t! _5 E9 c6 uend( e6 T! p+ ]# B3 I, x/ r% N
to do-plots
/ M) j' L- n0 Y! x8 }8 [# X* x  set-current-plot "Totals"
. H' Y; A2 J9 U8 m4 N' N$ m  set-current-plot-pen "turtles"
6 ]. h5 o& t& Y( i  plot count turtles( L- e( b9 K* }: E. J
  set-current-plot-pen "grass"4 I- w* V6 }% y/ u5 H* @) @
  plot count patches with [pcolor = green]
0 S% p1 `8 i2 q4 jend- u2 G! M1 Q5 v2 W5 K* C- C
可是运行时提示no such plot: "Totals"% f& c( H1 ]7 T3 N) d% b7 N
error while observer running SET-CURRENT-PLOT9 s, J& J. N& g( [, g2 E
  called by procedure DO-PLOTS6 X0 f% Z: h( D3 p* i
  called by procedure SETUP6 N7 s& h# H5 r  D4 l  f
  called by 按钮 'setup'" r& \1 }6 l" q) \
求大神解答啊
发表于 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
; [1 l: ?' ]; f8 h2 a2 |. N# n* M建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2024-5-3 13:17 , Processed in 0.014196 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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