设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12483|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]+ @0 G" N6 `  W
to setup
7 j1 g+ D( u% d+ \  clear-all
" I% D6 p' i6 g6 k6 a  setup-patches
. [2 _$ C; C. e& v. j  create-turtles 1002 Y$ ^% t$ x0 ~. p# y
  do-plots' r. k7 }, b4 s+ q
  ask turtles [ setxy random-xcor random-ycor ]
# ~$ Q7 w9 E1 Vend
- j" n9 Z6 I* u, n8 t# Eto go
: N5 E3 Q$ D* ^8 @  move-turtles: g3 h. k9 x, S
  eat-grass/ z: t: [) c) Z! X
  reproduce
1 E) J0 M! T& b: Q  i, B& q3 ~  check-death% f+ ~# |3 {! E
  regrow-grass
9 N- ]% S: A5 j$ u0 G" U9 B) _; j  do-plots
9 y# ]0 u; G+ q! oend) w9 s# w# z/ M
to move-turtles9 u6 ?) J7 V" m* `
  ask turtles [) P$ \1 M* J8 R
    right random 3609 X" i* T1 S7 c+ _$ I, y' M, ~
    forward 1" v) N! y/ p+ o% k( f, T4 L
    set energy energy - 1
% Q2 t& a6 ^+ o# N! c    ], W/ T. F4 F' @; D- r& c) B
end0 l  A) _/ y+ x" t$ Y
to setup-patches5 i' X0 P  d5 q+ V% P5 B% V
  ask patches [ set pcolor green ]2 x2 d  J' R( b) j! P
end" ~- F' ]- k! H; f, _5 v
to setup-turtles  A9 k! b$ Z8 u0 p: p: I
  create-turtles 100. _* e+ p" K* z( P4 g
  ask turtles [ setxy random-xcor random-ycor ]
: k8 w3 R9 l+ }! yend: T3 Z( U$ C! z7 b  s8 s/ a1 w
to eat-grass
" \; X' s7 w/ b8 I" h2 T9 b  ask turtles [$ P5 S- g# ~9 r. w: i: O, |+ r* v
    if pcolor = green [
1 `$ ^/ m4 s! P* d5 o. E8 j# u1 [      set pcolor black
* o2 N7 @1 I+ {, B- H      set energy (energy + 10)) t2 {5 e1 y' y: |$ ]0 ^
      ]
& ~4 j) y# i, U3 h+ P# G. \    ifelse show-energy?
, v8 }. G! }& U) d      [ set label energy ]0 X! L* l9 r$ c' A; P
      [ set label "" ]! a7 L' d, `  ]
    ]  n& u7 J; f% t  l* P- U
end
& l0 Y7 Y+ m, p/ d. Hto reproduce5 f3 l$ Q/ m1 M# h
  ask turtles [/ `* M2 U, p3 z, P; T0 B3 w5 g
    if energy > 50 [
* u: y' u$ N; C5 ]# W  S# W) G      set energy energy - 504 }2 ~$ W! c! O: w: @5 }& U
      hatch 1 [ set energy 50 ]
' D6 E9 G4 D2 ]9 }4 t- g# K      ]
2 r; j3 B0 u% [    ]
) D3 p7 E( o' U- W' p/ ]end: f" ?* L2 L# z4 v9 L7 N2 [
to check-death
2 X7 q- }. _+ E% Z! ^0 c" \6 K  ask turtles [+ G/ `* T$ E, Q( L$ p. J' g$ f
    if energy <= 0 [ die ]. |& ?3 S7 F* i2 F/ I
    ]
: w) g% P+ S9 z8 i9 aend9 H, _& P) X! h) `
to regrow-grass
4 s$ u4 V5 |2 z' G0 `4 y  ask patches [
. Y! o) \' y- a0 c( t1 X% s    if random 100 < 3 [ set pcolor green ]
) V1 u/ v$ D9 U% U4 j' ?8 l( w0 M- q    ]
! D8 O0 n3 A5 a( B' \" j5 U: dend" y6 U* E, ]( Z
to do-plots
$ z# C2 V4 s  p. ?' W& Z9 e: l  set-current-plot "Totals"# s  H# P' |" e! z
  set-current-plot-pen "turtles"
( n" m* ~3 K9 f/ K6 r7 ]( u  plot count turtles
; A* l* \9 O% F$ |# I  set-current-plot-pen "grass"
& X; N, ?4 Z$ H8 |* j2 T2 [+ [  plot count patches with [pcolor = green]& x( D0 A- j9 ]5 E/ \
end
4 q1 d, m4 H/ M) E可是运行时提示no such plot: "Totals"
& S; r2 Z. [2 V" ]. m  ?error while observer running SET-CURRENT-PLOT
, _$ O- V, `. o; r* G' j0 D  called by procedure DO-PLOTS  a6 u' W+ Y3 n& A
  called by procedure SETUP
7 v0 |0 N9 v( _' X. E# F  called by 按钮 'setup'
, R9 U& p& O0 C0 h求大神解答啊
发表于 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
* `) j. @/ K+ A2 Z" b. ?# ]建一个叫做叫做Totals的绘图框就行了
( q- A5 F& x* [% s4 T( s: A. T
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-8-25 20:52 , Processed in 0.018377 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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