设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 8107|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
7 p: u  c) @! ^- }to setup* H' i- a" \* s
  clear-all
9 X8 y- o" J. ?" x/ W+ k  setup-patches
* C/ I5 O( J7 R8 |( b  create-turtles 100
4 S# k* n) P5 o  `. r  do-plots! f; ]  ?3 j0 `) u$ ^/ O
  ask turtles [ setxy random-xcor random-ycor ]  Q3 E+ ^8 S1 k% r
end' d) n4 ]: x' c; Z) h
to go
+ u" `' d8 Y* G  move-turtles" ^3 e$ N* ~; O/ Z0 J
  eat-grass2 Z$ I/ T: b2 y9 x1 w  X0 j# X
  reproduce
) ^1 y7 I2 J# C$ e9 {2 R  check-death
1 n4 r, [" H$ W6 D+ p  regrow-grass
/ r& |( p- s! Z: r$ d8 v5 f, ]  s  do-plots
& J: R0 Y) S4 d  F+ O+ oend
$ R8 c: |, M  K$ i: X3 J6 Nto move-turtles: A1 ~6 u. X! L3 A! b$ ~" ?
  ask turtles [
0 g, S: G6 M- w( l0 R) `( h    right random 360( s$ }0 ?" e; b. ?/ f
    forward 1& a. c; B7 T. s( j% R
    set energy energy - 1
/ N1 ~8 [: @. G9 P; m- K    ]3 B' U) O, Z7 B3 h0 F
end
$ a+ e! R( r0 O" E; v4 a7 Sto setup-patches
1 M2 g5 [% `; Q1 x- K7 e) E  ask patches [ set pcolor green ]  R5 I& h* S# l4 \. ~8 e( g
end3 ]% [5 C& s, V% T# d: r
to setup-turtles) N$ }  ~6 n8 d  [/ p' ~" ]
  create-turtles 100
5 o% r3 i% b7 s: k  ask turtles [ setxy random-xcor random-ycor ]
) V/ s6 D5 K. K6 M) P2 Eend# j9 L3 s& w0 T; T. ~
to eat-grass
& ], [: C, E" c- x( C" p  ask turtles [( l7 w6 {" q$ u5 R8 U; F8 A
    if pcolor = green [$ M# z3 b* u- H1 e* i
      set pcolor black5 \; i( Z! i/ h  n# D! B* t5 p
      set energy (energy + 10)
( J$ ~, e! R" B8 e% K      ]
9 {% G  |6 ?6 C9 Y- `: e    ifelse show-energy?% e* f5 U( Y9 y, I% l
      [ set label energy ]
& w, i6 ^$ ~8 k: h: w1 h0 H      [ set label "" ]
" L$ q. C+ v  r* H    ]8 h) T+ c6 j# [$ t" h/ r7 U
end
8 s/ T8 j4 D6 z7 J8 h- ?+ ?/ Ato reproduce
, O+ r$ _' M3 B! I  L  ask turtles [
$ \: Z& W) M  e+ m4 h# V% ^    if energy > 50 [5 t! L* H% d' a$ q  u& C0 t
      set energy energy - 50
- Y' x5 p- G- d* G# H9 ~, m* j      hatch 1 [ set energy 50 ]
9 i% y+ Y* w5 r1 Z2 v1 U% C      ]( l5 k' e6 M  r- b4 o
    ]5 ^& ~  c; z4 @& C+ x( d
end6 o/ t4 q6 a2 _) {! R/ y* R' R5 _
to check-death
. a1 Z7 i7 E" U( J1 C  |  ask turtles [% q( r) I, @  A# z) P" y0 a- J( M# J& l
    if energy <= 0 [ die ]! }6 G- q' E3 [
    ]
  Q7 C6 w$ h, L0 }end' K8 w+ H8 Z' R: z
to regrow-grass* H+ ?# e; ]; M4 Z
  ask patches [
3 D" d5 \" T' e) g    if random 100 < 3 [ set pcolor green ]$ o, @6 f& l3 G1 U: F9 D9 j
    ]
2 N% J) r8 @# V" n% b8 Aend
  q+ `5 _" u8 d+ e' x9 N3 sto do-plots
6 l1 b  {2 B" ]1 d9 ^9 z. J% l  set-current-plot "Totals"8 u/ f8 w( P' P) i$ g6 S- s+ M& B
  set-current-plot-pen "turtles"
3 t& R5 _1 A4 Y  plot count turtles
2 n! Z* b  Y4 P; ]; o  set-current-plot-pen "grass"
* K" I0 A, K' G. B! g* ]  plot count patches with [pcolor = green]
/ L2 z/ `9 Q1 D$ H+ Y) ~( J1 Send
! u7 S$ A5 A3 Y0 r6 c8 R可是运行时提示no such plot: "Totals"# M% g7 F" p" x% w( N
error while observer running SET-CURRENT-PLOT
4 k$ t. ^4 o3 `  L. f  called by procedure DO-PLOTS
+ V/ A# V7 s2 |  called by procedure SETUP
/ R) Z; b6 ~) m, W7 F. S. S  called by 按钮 'setup'
& n# d8 G2 `0 ?) E3 b求大神解答啊
发表于 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 p9 l$ d; V! K
建一个叫做叫做Totals的绘图框就行了
' o& Z  X. S8 [2 r
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-7-13 01:18 , Processed in 0.016111 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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