设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10208|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
. A6 l/ a5 u& |to setup* L& Z) H) {4 W3 \  ?/ z8 r
  clear-all
& z- D* I! T2 s" `6 ]6 K: r# V: w  setup-patches) W  P' I7 y) s5 S
  create-turtles 1009 ^0 j% `# {/ j
  do-plots
% n' N+ {! \( ~  ask turtles [ setxy random-xcor random-ycor ]
) j5 p# J) J. m* L$ Q7 Mend* C' `" M/ U+ `3 a* \  l
to go
& i3 l% s+ @0 ]/ E& c8 S  move-turtles! E, c/ m+ `. l. O" v
  eat-grass
2 c6 p) B( @. C  reproduce1 N& {% V6 ?# i9 M( E- b0 u
  check-death& Z4 b5 Z3 U9 [! j* S
  regrow-grass
( U& A: m( {0 F% X  do-plots" Q4 Y& L3 E& s
end
0 }9 p, R, }0 ]0 I1 nto move-turtles
2 ]4 c* c! q6 `# \2 F. u  ask turtles [
/ L  ]$ a/ l! {7 l3 N% r! c2 q# ?* y    right random 360
3 I7 q3 c7 m1 R- Z0 I. Q  i/ A! j    forward 18 y7 E2 Y" l+ J  I. n# ]% c
    set energy energy - 1  e* \& W4 i8 }- q* I
    ]
& p3 i% w  L$ }' c  L8 ~  W! Yend6 L; \* }. e8 W5 s
to setup-patches9 l4 Q: K& \6 s. W) w5 E
  ask patches [ set pcolor green ]3 m7 U7 h2 ?/ u) I7 t/ D5 ~
end; x3 O( J, X+ K) a8 R
to setup-turtles% l/ j: N9 `% D- |( l0 h* D
  create-turtles 100
  Y/ O2 R' y6 R; x  ask turtles [ setxy random-xcor random-ycor ]
  G) R8 {* R5 o" O. kend# O) `( N) D  [. s: o8 y! h
to eat-grass
/ w7 X; D& K4 _3 c& P5 o  ask turtles [
, v: J8 V2 v2 s7 F$ i    if pcolor = green [
# _+ X8 ^$ ?# `% J: T7 F      set pcolor black4 V* c0 V- P, ]$ P
      set energy (energy + 10)
& k; Z( f; Z! O) h2 Z0 t      ]: y4 w) {! J! E! q9 C
    ifelse show-energy?( G9 D# X: B4 Q) L
      [ set label energy ]# V, Z% B7 i4 ?0 N2 X) E
      [ set label "" ]5 N. ?3 Q0 ~9 Q, g
    ]
0 n3 m2 b) k6 [/ Tend, L  Q+ B  d- |( n; M, b$ I
to reproduce0 z6 l; I9 i5 g! ?! W  M
  ask turtles [' J5 d: W: W/ Y; A: ~- ]" K2 Y
    if energy > 50 [4 p4 O' P9 M$ d, F6 m
      set energy energy - 50
6 s# I- e8 \2 L9 F4 H( w7 M( A      hatch 1 [ set energy 50 ]) `9 \* w2 a$ }' Y7 {" R
      ]
- f3 \* e' k- v9 T, M; n+ Y    ]3 I% j9 F4 A5 A* y$ O  X! W: K
end
: m$ H! _) |$ v) M. z* _7 yto check-death) D- N: c: _( y# q6 |
  ask turtles [# j# n8 |* X% G, ?: s1 T( t
    if energy <= 0 [ die ]8 s7 r! d( j- U. p5 x8 y
    ]
( f3 a5 _/ ~) K% Iend
% L3 x; C0 I% n/ ]; ?. ito regrow-grass  i; `* C1 G1 X% L2 e/ R
  ask patches [8 p* |7 F5 l# [! W1 _
    if random 100 < 3 [ set pcolor green ]( _" q, `6 N$ _* w  h5 M1 W
    ]
3 f2 v, ]1 W5 H) w+ Q) h" Fend! x8 R, S. x: {
to do-plots) I4 C3 y. {6 S7 S  }0 D
  set-current-plot "Totals"" e6 D  i8 ^2 a4 F
  set-current-plot-pen "turtles"/ A: Q6 W1 Y6 n. m8 A% O) p
  plot count turtles& ]  z) Z; U9 O: M: z
  set-current-plot-pen "grass") x! p* N% g. `' O( P6 B
  plot count patches with [pcolor = green]1 x* j  b. {/ n0 D& ?: U9 A
end! O+ {- K% [/ b. N/ r. V
可是运行时提示no such plot: "Totals"6 x5 U  s. r$ B( y! S3 ]5 g
error while observer running SET-CURRENT-PLOT
  `; C$ x- G; M; l3 ~  called by procedure DO-PLOTS- R; A* p1 g: j5 f+ Y% E, R% S; S; P
  called by procedure SETUP  a. F, y$ E, v7 k1 }4 f
  called by 按钮 'setup'2 @. Y4 o7 z& m) n1 z! 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 . Q  }( ^, n# @4 S
建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-2-23 22:12 , Processed in 0.017606 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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