设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11604|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]+ [1 l  O8 o2 u& y/ i
to setup$ Q- ]" \  _2 o+ \  ~
  clear-all# X  ~' M7 F5 D7 q  ^
  setup-patches
9 K# v' D1 O2 o  create-turtles 100
% T5 U5 O% |% P) d  do-plots
; M6 I5 e; c7 t: Z. [% x  ask turtles [ setxy random-xcor random-ycor ]8 R* ^5 n9 Z0 M, ?
end: G2 J! G6 E% ~
to go
; Y5 x6 d7 p5 _$ l3 O9 K8 l  C  move-turtles! M. U, ~' s, y
  eat-grass
3 t: b8 F( Y- I  C9 n7 w  reproduce
* d0 ]# X- n2 B: ^2 H' z9 f  check-death
& w4 V- i' `) l0 b( u" m! [; b3 h  regrow-grass0 L* Y, p8 `- k, ~& ^8 @* }7 @( T
  do-plots
- \% G/ U2 W; Z6 {- n; ?end
  d! p  M$ y7 r2 P; Vto move-turtles0 m% u% X& L1 n$ ]# g! e
  ask turtles [
9 u9 ]# x! L/ C7 h5 d% }7 a    right random 360
9 q) G2 v. @, J# e: n4 n    forward 1
3 t. g+ n+ F2 y+ ?6 O    set energy energy - 1
  V' G! Q1 M* g8 M! p    ]. {8 r3 D! V. C  h$ y
end
7 r" F( s; v7 X. \) L7 Eto setup-patches
. B( S. l! M6 V+ N  ask patches [ set pcolor green ]+ @1 A* d6 b* X1 Q, M4 {+ A
end
" `) [6 J# z4 v9 M( ^" Dto setup-turtles
" i3 O0 Y5 Z& \$ H) v( y  create-turtles 100
+ K: P: }7 n- W( ~8 Q: t- }  ask turtles [ setxy random-xcor random-ycor ]
/ P! W$ U, @  J8 k% Q+ {/ Dend0 f8 d  k+ j6 h$ c! q9 P
to eat-grass2 C' H. m) H3 P! B  x! S4 B
  ask turtles [' {* A4 b- Z3 M" {* Z
    if pcolor = green [
, b: Z9 ^' i. q, ]      set pcolor black
* ]3 Q+ |9 f2 b, T/ m      set energy (energy + 10): F1 a& M7 Q6 i4 w7 }
      ]1 o+ w! q( u& K( \5 x6 M
    ifelse show-energy?
3 K- d9 T5 j- [, L- G      [ set label energy ]( q: ^9 i0 \% z, W2 d) i5 I7 {
      [ set label "" ]
- s0 y# p: }$ j! e9 H; w& W4 W    ]. U, t# ?0 u+ i% z( h' B) b8 }' Z
end5 }% ~. x  }2 N# H7 a2 }" r
to reproduce
9 [* E0 T- t- [: a' L( ]  ask turtles [, E0 D( H7 X' J, R
    if energy > 50 [5 o1 c9 }/ T8 e# |' s+ A0 L
      set energy energy - 50
" |0 b7 j9 H& D& Z      hatch 1 [ set energy 50 ]7 Z/ [' B+ }# S+ e! s& [
      ]
+ u. |* q) J* _0 b    ]! W) ~; x. S! Z1 J
end% M' Z" \* w, F8 P9 \# k+ x( F$ _
to check-death* F& C( b+ |' ^: ?4 j
  ask turtles [/ z( [  ^& @/ Q$ J8 t
    if energy <= 0 [ die ], ^4 l. Y* m2 L. _( h- y
    ]
% p! E" ^: @$ h* \& Z2 j  vend- [) \( z+ R* C% g% L; j
to regrow-grass
( h# j' A- g* z& r7 x  ask patches [
' ^" V; I' x( x& u) o. D    if random 100 < 3 [ set pcolor green ]
" E& ?6 V8 u& H/ h3 z    ]
  ^9 o, I" Y* w1 Dend
$ K9 l$ D0 N, S0 @* v' H  v" o9 Yto do-plots
( _: D0 C" R5 c8 I/ w% T  set-current-plot "Totals"
' u( B  E/ H4 Q* Q1 z  set-current-plot-pen "turtles"
6 F4 m3 Z$ U+ J3 f( B  plot count turtles2 o* B& S: o% d# Z, {
  set-current-plot-pen "grass"' `/ J4 a6 M2 F! y) _! R# t+ `9 u
  plot count patches with [pcolor = green]
% Q: H! O6 U* Wend
* t+ Z6 @$ I% e8 g5 y可是运行时提示no such plot: "Totals": N1 C9 t7 U4 f% X6 D5 K2 p4 @4 Q; W
error while observer running SET-CURRENT-PLOT( h7 J3 i/ H1 Q& f  V0 @
  called by procedure DO-PLOTS
% s4 a( _5 H9 V# V  called by procedure SETUP3 i; n, r2 T: `6 U- R) u" D
  called by 按钮 'setup'
/ ~! Y+ H$ K2 A  T3 O求大神解答啊
发表于 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
8 T2 a4 _- v6 b' Y' g4 L+ A& `建一个叫做叫做Totals的绘图框就行了
: F- _& i0 A# `+ P0 o. U% S
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-6-13 10:44 , Processed in 0.013452 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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