设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11551|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
4 _( X3 p2 D9 D, {' {% a& _6 vto setup
6 @8 n5 {) p6 g! b3 ]  clear-all
4 f  v: g/ y4 d1 v+ X  z  setup-patches$ \) g% E( L- b2 W) S
  create-turtles 100
0 I9 A( S0 T% _, Z# U. H: ~  do-plots
) I( C) `4 \: j. y  u8 X  ask turtles [ setxy random-xcor random-ycor ]
; F* }/ i1 V  `/ P" _% }  Tend0 ]+ O3 v2 ]3 e& }
to go
0 J( Z9 _* _7 h; N+ G2 S# Y  move-turtles
4 p* v) N7 t( l: S; R$ Y- ?  eat-grass$ T6 j. C6 _6 G& b& y
  reproduce
: N3 v5 F  f3 s# k7 I6 ]  check-death2 H0 x* G6 [- Z; [7 ~
  regrow-grass
" D5 G8 o( @8 y' u9 J. L  do-plots: G3 ]8 z& l: {! Z. x# ?$ o
end! y6 B2 k, s% V
to move-turtles4 |. W& ]" w0 D0 u9 o& k, m- l
  ask turtles [1 y9 \5 U; w0 V( D" i! M
    right random 360
3 g2 J5 v$ u4 ]3 @& \0 a    forward 1
$ g5 y% w5 Y5 ?+ `! q9 o' Z+ G" P    set energy energy - 1
* h; Z  R2 ?0 f& Z2 A7 U- l    ]
7 k: v2 ^! g7 k8 H/ B/ w7 z& Xend1 D/ C% @+ ]: S1 I$ V
to setup-patches
8 G/ u* |% D) {% T% C! X  ask patches [ set pcolor green ]
5 L! ^2 j% C  Qend
- Z2 d# m3 Z5 Sto setup-turtles
( C  s+ \5 \) R  create-turtles 100' m5 L  D" M' f$ Q' b' X: M
  ask turtles [ setxy random-xcor random-ycor ]
0 M+ \5 ]8 b9 K  Kend' i8 B: E* y+ U7 U$ Q2 ~! |* u4 w
to eat-grass5 I6 H+ Y" l: Q& X
  ask turtles [
. F! N  H: `7 k    if pcolor = green [
1 g: M4 m& Y, v, s# H+ G  d      set pcolor black# N- o* b9 W: X! y) z8 }+ E
      set energy (energy + 10)
0 J" r0 u4 F0 p' q      ]
- o2 S0 l) L0 O2 ]# S" D  ?% x    ifelse show-energy?; f# v# V* X2 Z7 K
      [ set label energy ]
$ \' n/ Z4 A8 ?0 ]0 B      [ set label "" ]) [  f4 `& Z0 e5 z
    ]
  k/ d; g& M8 Q) ~7 \end! T. w, X  f$ a" k0 V1 e
to reproduce
, P5 A  ?# d; a  n& `/ x  ask turtles [, T& o/ k; g7 g+ a  c
    if energy > 50 [
; |! N* @6 Y/ @# E/ j+ A      set energy energy - 50
& f0 x8 W7 L  q" t8 g& {      hatch 1 [ set energy 50 ], |* j) U! n' P3 d& R1 s6 x
      ]) B9 m  q7 |! R9 ?
    ]' {4 o$ B( r  t! a* Y, T, e
end
  E/ v+ o# r+ b/ S6 G% u3 Eto check-death
! u) n& Q  O) |  ask turtles [# s+ m3 C- E4 i  x7 g
    if energy <= 0 [ die ]
0 F. C0 {+ `9 s3 d# Y3 d4 v    ]
: l( l. u3 @( ~( ]4 tend
2 Q) Z) x. M: I: p" rto regrow-grass
+ D+ ?, _9 q4 w) X2 `  ask patches [
1 T5 e6 ^+ x! R4 _    if random 100 < 3 [ set pcolor green ]
# T& y% Y  k/ k    ]
4 a- H  T- R6 F  Hend' ]( [! S$ Q+ o6 N$ y5 T
to do-plots
9 B2 ?( I' B! v* a  set-current-plot "Totals"4 Z- e, }4 L5 d+ ]8 s
  set-current-plot-pen "turtles"* f, L4 e; W5 c4 ^% B" u
  plot count turtles$ D# v* {( ]1 @% f6 n! r/ ^  H
  set-current-plot-pen "grass"' E1 H( t+ B% C$ j
  plot count patches with [pcolor = green]
, g0 ~0 I' H1 |2 n# ~end  i& V9 }1 H2 U$ w% @* J
可是运行时提示no such plot: "Totals"
5 h4 o. r3 c6 l* F( x6 O" V  Y/ |error while observer running SET-CURRENT-PLOT# b/ T$ O7 G, L5 p4 L6 x, Z
  called by procedure DO-PLOTS% n1 |$ S' X8 Y  r( q9 A8 L
  called by procedure SETUP
' e6 U: L7 I7 J6 J  called by 按钮 'setup'
! J  t3 u0 U/ U' x" }求大神解答啊
发表于 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
! F* Z/ D" J7 R( b- s建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-6-8 02:27 , Processed in 0.013696 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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