设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11669|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
* h# y9 q' i4 Ito setup' `2 n( U) Y2 f  r( f( k
  clear-all( a$ x, _5 X9 `' Z6 f! Y5 F
  setup-patches
4 r; ~9 }: R+ K$ f( o  create-turtles 100/ ]" N: i, F) {; x+ X
  do-plots
/ x/ F5 w7 }( T- S  ask turtles [ setxy random-xcor random-ycor ]
9 F3 g( T7 q5 }) oend. t( K, C, m7 ]1 Q6 I
to go3 j6 |; x% h  g& x0 |. o2 ?
  move-turtles
  y: X5 X+ M$ ^( X+ }- r1 K  eat-grass
3 _* D/ y  @/ Q7 e6 R  reproduce
  D2 \. ~% g* U4 Z  check-death
6 Z- [9 E& i7 b2 ]' s4 d8 h; ]1 I1 m  regrow-grass" y2 G# T/ A% c
  do-plots4 Z; L8 t2 t8 F
end
9 a2 M9 W( N/ ^to move-turtles: u2 |/ ^6 m6 L
  ask turtles [
! T8 W" c0 z/ k" [4 C    right random 360+ ?* L8 d- L: |, g# c
    forward 1- ^3 p) V2 n. b, a' V1 x9 s' s4 h, C! k9 `( ?
    set energy energy - 1& p# N4 e8 j" s( j2 r
    ]
" w$ a' I6 @3 v8 |$ ~' [+ }end7 j# L! a" w, Y# F4 Q' I5 M
to setup-patches
+ X2 N0 |3 `3 [. P: G' v  ask patches [ set pcolor green ]5 t4 H9 A7 u3 E
end
0 a: B: h: F! Q/ S+ Tto setup-turtles
) Q; g6 \4 ^. ~! j' S  create-turtles 100# h& Z% M% i& @
  ask turtles [ setxy random-xcor random-ycor ]
7 ~8 l% }3 M8 {, w; \end
3 A3 O, d9 R( g2 `8 Oto eat-grass
- l% {" l( B* F  I* L# y) K0 e  ask turtles [
0 W# T2 _' N2 c4 J0 C    if pcolor = green [" w! ?5 V( x- I7 Q
      set pcolor black& u6 I+ T- R5 S2 c# ]
      set energy (energy + 10)8 ?" `, c) k5 |8 }
      ]
% E+ b) L* q1 w8 r2 H% P    ifelse show-energy?( y9 k- f4 C$ r; t( b. o
      [ set label energy ]
5 g$ D# q1 q" K# o, b' B      [ set label "" ]: e; P- @+ L  n
    ]) B: Q0 N  e$ S
end( E2 N; m0 [5 S$ C
to reproduce7 G- ^$ m$ C7 \9 e, |% H0 H
  ask turtles [
! d2 b8 Q; B3 r9 V) Q- V    if energy > 50 [
2 ~4 B4 j  ^# z      set energy energy - 50
" S+ V7 O; S8 ~6 [  l      hatch 1 [ set energy 50 ]
5 T; ]: M1 c% S3 _4 ?4 _6 j      ]
( [5 \9 c9 B) X: }3 D0 V% T    ]
. Y' y, c/ Z( p! v, V) T& Send
3 G+ F. k9 Y2 W! Q) H) Gto check-death; }. H6 O; E. k- r# c
  ask turtles [- d* @4 K0 W2 `# ~! \" E$ n
    if energy <= 0 [ die ]' f; V. M4 t/ P" `8 j* Z0 f
    ]
! m' ?5 B+ c; B( E5 D' g$ d; H& ]end' B: I! I+ Z$ e3 D
to regrow-grass5 @6 R% p$ M4 J* b9 g) q
  ask patches [
& o+ V/ g: h! {7 e2 I6 ]9 L    if random 100 < 3 [ set pcolor green ]
  v% z* k1 ^! [    ]2 j7 T8 A" s# h7 @$ O+ N
end
5 {: L- P2 e& y3 X# A# G" nto do-plots+ C2 x# [! @8 Z& `/ b
  set-current-plot "Totals"- }- c5 W# V2 y' Q$ M
  set-current-plot-pen "turtles") y! b3 I* q7 L& E" \" _% ?
  plot count turtles
$ a: ]. B4 D" o6 l% b  set-current-plot-pen "grass"
' d  B' S- I, g  b; `- }6 b6 J  plot count patches with [pcolor = green]
* @/ m7 Z2 w" U2 ?; J% E7 C7 Q0 {end# p9 N  g; t5 X0 w/ Y5 T
可是运行时提示no such plot: "Totals"" Y" a4 h& Q1 T0 i7 S
error while observer running SET-CURRENT-PLOT
) q( Q1 J" m5 r8 N& j- u  called by procedure DO-PLOTS, s4 @* B  h# ^; G8 R* z# S
  called by procedure SETUP
- O2 i7 ]! D. {  a1 ^  called by 按钮 'setup': u5 C. w$ S" m' C1 U, A
求大神解答啊
发表于 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
3 w& E2 X% {7 C4 l+ X建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-6-17 16:37 , Processed in 0.017425 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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