设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9836|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]& p1 z% ~4 B# J! X. f
to setup
" v7 H' W( r  [# ^- l) l  clear-all
: V  Y  ^. n* P% x" Z2 [  setup-patches
4 H( ?3 G4 D, m2 a) {( U  create-turtles 100% J+ w4 C, M, \: x
  do-plots
' Z. s6 v0 S9 |! `/ {  ask turtles [ setxy random-xcor random-ycor ]
9 V/ c" H. _# S/ N: q/ V2 a4 H6 x& rend
( d9 S  K, x9 Q% \1 |( Jto go$ }! g6 s' L! e' m, y& m3 G& u/ c
  move-turtles
+ b4 c. P0 b7 M% Q) n  eat-grass( W3 L7 x, k6 z- n
  reproduce3 M; @! ]$ ^3 d" x: P# M* [9 ~& c
  check-death
: Z% k1 Y1 ?6 q8 n# B  regrow-grass
! U3 O4 D6 V, o3 e4 e  do-plots
) m  Q: o# s6 N' g: B) v5 zend
7 H2 T1 W( P' J2 ?# \+ x. Y) sto move-turtles
4 a/ t& k8 |7 A; l- a  ask turtles [
; U7 I1 X8 z7 \. E    right random 360
+ c. J: b( j! l6 B1 W    forward 1, e2 n. W& F3 ]- H7 V- C
    set energy energy - 1
! n& U& w4 x3 `) Z" Z9 o7 j3 _  J    ]4 |) ^4 v% x: F2 l
end
, x+ O( {2 F0 H, L; a2 X! dto setup-patches
( q7 y$ \# s% i  ask patches [ set pcolor green ]
4 x% S" B3 k6 I6 Fend2 {2 D% N9 u6 P% ~
to setup-turtles
2 {+ I+ ?, l7 I# |4 s$ e' Z) r1 ^  create-turtles 100
7 v* o3 r7 X, H  ^2 w3 I  ask turtles [ setxy random-xcor random-ycor ]& q) n; s4 W) A: H4 w8 k7 X
end* g) H6 b) K/ v0 T2 O/ \' M8 U
to eat-grass3 ^8 J$ [. J9 ^" J! C
  ask turtles [# J( d' }6 L( E+ E" i& \
    if pcolor = green [, x" g/ x/ S7 B4 A! k9 r" v0 e; O
      set pcolor black8 g( t* L  r2 ~* ?# `
      set energy (energy + 10)
- B. o' `4 m% U0 \3 w9 M- i      ]" _3 g& C5 ^" p& D
    ifelse show-energy?
1 B3 V  B* ]- I: o, R      [ set label energy ]
0 }0 {3 i, H$ H: \( o      [ set label "" ]6 B6 \3 z+ S' W) I1 V4 A
    ]; L+ ]( a+ h+ m# B! u/ e0 ^
end
  T! V, a" r& ?to reproduce
5 R- E4 E7 {/ W- @  ask turtles [
) @) ?3 E  ~, G6 Z/ i& D    if energy > 50 [
( ~  d9 a, j3 z3 w      set energy energy - 50' X; h4 J1 b4 ]; B# L
      hatch 1 [ set energy 50 ]! S5 U( F. r/ ?, w* B* ~# z
      ]- [- Q; d" @# r9 J% C
    ]  g5 g7 f, T2 A* j8 _
end
) u1 {  @: `6 Jto check-death; ]7 r+ o7 s: o. q4 {  a/ Y
  ask turtles [& o. [2 E- m" ?2 A+ b
    if energy <= 0 [ die ]! x( D5 {1 z. J$ e" A/ K
    ]
9 E" j- B  c+ c, A4 a; ^( nend
- I0 t5 a& m- N$ y+ Rto regrow-grass
' ~4 d" Y6 {' q1 ^% Q+ {; Z  ask patches [
& ?2 A, o3 z" o) U    if random 100 < 3 [ set pcolor green ]
+ ^6 z2 m& q( ?    ]3 _* _; Z6 @+ c: `3 H% I/ j
end7 C: u% M( b: U- \
to do-plots0 v7 S& C, x% J6 [! W
  set-current-plot "Totals": o0 x7 d8 B5 _* a" [$ V/ {0 @
  set-current-plot-pen "turtles"7 y; i. s# ]: n1 L7 w" A
  plot count turtles$ J0 o0 R( F( \; _/ r
  set-current-plot-pen "grass"
2 `$ A, ^7 N! X! x/ ^6 }  plot count patches with [pcolor = green]
( S- q+ j9 p# Q; c' k; ^" oend
6 x1 X! \5 c5 V9 c1 ^可是运行时提示no such plot: "Totals"
" A7 E3 V: ?8 t6 {: y( Uerror while observer running SET-CURRENT-PLOT
* ]6 z& E: \# q2 ]* u' U4 I  called by procedure DO-PLOTS
/ h/ M4 G3 ]7 N. `; ^, l  called by procedure SETUP
1 @8 x6 s  n6 v( c3 T+ W# B$ j  called by 按钮 'setup'% k+ a$ ~) O0 A5 W$ D
求大神解答啊
发表于 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   \. T& b3 E+ t7 e
建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-1-25 03:13 , Processed in 0.019703 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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