设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9141|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]1 r" ?. ~' V& `7 F+ ^$ s2 n$ ?
to setup
( P0 ^$ e3 S" }+ y  clear-all
9 r" b0 S; t4 g3 c  setup-patches
0 R$ t  T, d; W7 P  create-turtles 1002 J, u/ @6 d4 z8 S6 e" y
  do-plots3 _  d  H+ Z% P- Z
  ask turtles [ setxy random-xcor random-ycor ]
$ e4 ]# f. o' r8 L' a' D3 }  fend
  [% k* |: @  E: _2 K. u8 `" lto go
4 x; K9 t* u; Q9 ~- L  move-turtles
) ~! o$ U; W1 W  eat-grass% q3 z2 b4 N. ^' ?& Y+ _8 [$ {
  reproduce% @& ^0 u, C# v
  check-death/ ]/ z+ X) n* ^7 v) L" y
  regrow-grass/ l* L% E) ^- ^6 `. |6 T- N1 M
  do-plots
3 \( B$ T* e/ m8 xend- S2 i' M! F( \6 h. ]/ p9 Z' y
to move-turtles: x7 G% {. ~1 p. @6 \
  ask turtles [1 ?8 P' {* b' [5 x) E# T1 o
    right random 360
( J6 S6 v, e- h5 }. m    forward 17 I3 c! t3 P( t* M# e/ u1 {+ g
    set energy energy - 1& L1 f6 x' t; u# @# p& J
    ]0 u$ |, D& V4 T* G9 z' l  l8 a2 v
end
5 G. K  g0 V! {# ?$ W" bto setup-patches
  i( ~4 v& N# Z6 K  ask patches [ set pcolor green ]
( |7 _' P- P9 H5 S4 X& a% K. Jend2 n: _* H/ F$ y9 `" t/ r
to setup-turtles4 U2 s% X' f8 s# s9 ?9 l8 U
  create-turtles 100  m8 f1 M- O$ q& K1 a
  ask turtles [ setxy random-xcor random-ycor ]; g; C( w4 {- ^% J
end
6 s7 \1 l8 @) m+ p( t. W, Xto eat-grass
) }5 i) X: M6 c. b, `* F  ask turtles [% t. P# o" b( I$ {0 S- ^) a! Q
    if pcolor = green [
* Q. L1 ~" s' U, D$ x" r7 w      set pcolor black
( q1 Q/ m+ E" T; e; Q9 E" |" P      set energy (energy + 10)
1 D$ J5 w0 |$ ]( f      ]
- b& Z3 j& C& ?8 D2 N! @" o    ifelse show-energy?
$ y4 h5 O1 X$ D/ K& j      [ set label energy ]
9 i8 r: a/ o7 c: T, h5 h$ w" J      [ set label "" ]
; e  P; B  w5 f    ], Q. U" D( a2 F8 O* ^+ [
end% h# D' {# o* P5 L; o* P
to reproduce
3 S( U- p' m; t! G3 y  ask turtles [
3 z9 t( E; K" s    if energy > 50 [! d5 Z4 ~/ s- w# P- O$ N
      set energy energy - 50* ]1 r/ W1 H+ Z$ J% t  G" S7 F
      hatch 1 [ set energy 50 ]  k+ j3 e, L  E% ~% C- h8 z9 U: U
      ]
7 F6 B8 w9 n# q# b    ]
  C6 ?) \, e) _! Q5 Y7 nend+ n( h- G) @" ]0 l) Z! {
to check-death
1 _- |( W/ B8 q! J, e0 K8 |" p  ask turtles [
" [! D. {8 X0 c2 }+ v    if energy <= 0 [ die ]
, w! ]: H* Q6 ]8 ?" M    ]
; x% k4 Y! O% w/ r, U. l8 Y6 E6 Hend( p, J) I! z% u! k1 O: I5 q
to regrow-grass
" o- C1 ?' G! {/ _2 P  ask patches [2 j5 B; W0 d5 X" W; w2 a
    if random 100 < 3 [ set pcolor green ]3 W# }$ L5 h; N* z0 u
    ]1 _9 |+ i" J- C- e. y& j
end7 r" T6 K1 k, y  |# s
to do-plots" F2 G) o& ]7 H$ r2 n3 @; F
  set-current-plot "Totals"
7 b+ l1 t2 l8 u- B; h  set-current-plot-pen "turtles"* ]" Q0 t: h5 }5 b
  plot count turtles
% n1 W5 ~' Y& ?4 D$ B: R# L% J  set-current-plot-pen "grass"
# C9 e% a, i+ y  q& ]  plot count patches with [pcolor = green]
+ v7 W2 a: Q2 |$ N+ n# yend
+ `# M# s7 S4 V3 x9 ~: {可是运行时提示no such plot: "Totals"% u8 v9 R& ?0 @. p2 h% [
error while observer running SET-CURRENT-PLOT
& ?  k/ ?; f  k7 a  called by procedure DO-PLOTS7 P# h" A3 x, C
  called by procedure SETUP4 p! S+ Q6 k: p3 r( `' P
  called by 按钮 'setup'2 `9 q  u. J0 q' N' p0 p5 v* a
求大神解答啊
发表于 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
" w9 ]' E7 L) [! t$ v: B建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2025-11-19 23:52 , Processed in 0.023580 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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