设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10244|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]/ v! s% I2 F- a6 t
to setup0 J+ Z3 t- z) R) }% L2 N
  clear-all# M; G4 q6 ^6 A- s5 u
  setup-patches, I5 w7 S; D, k8 J: P' x
  create-turtles 100
- W8 j9 ]1 A* W/ W  do-plots* [* P+ d9 ]0 A# Y2 r$ \" ]/ J
  ask turtles [ setxy random-xcor random-ycor ]6 ~1 r1 N* k% ?. Y8 e1 R7 _
end5 E( x/ e' V( T! D: O6 ]0 ]! o  M
to go
+ V, N% s. g! S$ p  move-turtles
  q3 j5 f$ `. o2 }" h$ Z0 |% `  eat-grass
" Y4 y4 r  a4 i  reproduce
& I1 k) Q# Y4 k$ z( K  m  l) A( r9 k  check-death7 C, |4 M$ k/ }" a( \, t
  regrow-grass
! o9 s& \% J' h& o# x2 S  do-plots3 S* K* M! J6 P
end
+ D( i" O' i% X- Gto move-turtles
2 l0 Z1 |+ M; q7 I, g1 R* L3 {  ask turtles [
. s  ~% r4 E& E) n) g    right random 360
+ p4 c, [; t" F2 ^- e    forward 1
' ?% B- ^+ Y: ^) W6 B    set energy energy - 1" B: P/ ~& S9 ~  V3 s' R
    ]: }! `- [3 c. z, k
end) F& {# x- ^, R0 }* J
to setup-patches
' P) c% Y) j# `4 y- X# m  ask patches [ set pcolor green ]
$ b. a7 |0 v- S/ e9 H, t4 G0 gend
& C& j+ Y4 n) F% c# \' K5 L. }to setup-turtles
. ~; M; ^8 W# _* s; m" X  create-turtles 100
' ^5 L0 E" R/ f3 [8 E  ask turtles [ setxy random-xcor random-ycor ]0 _; X8 b' A" [
end+ O% }0 n3 h6 D) z$ Y7 H7 ?. C
to eat-grass
  ~( V+ M# Z: y% n; S/ `; o( q& j  ask turtles [
! }* j) c  K' d, V    if pcolor = green [7 d' t& }* h- L* g" Q
      set pcolor black
* G; ?7 s9 t7 c% N# e" R9 s      set energy (energy + 10)8 G7 n9 W  t7 ~' ~( [! D/ t' h
      ]
& s9 [6 _* Q# [4 A# q6 t, A( L    ifelse show-energy?) v8 f3 E% {& ?/ t( b
      [ set label energy ]
- {  m% s/ b: y3 @! ~; O1 e0 ^      [ set label "" ]# c3 G- O& }- {+ F
    ]
; W+ Z7 h2 a5 ?end& U  T1 N3 b9 W4 U0 _
to reproduce7 m3 X0 [/ s: r/ W1 |
  ask turtles [$ m- e  P) u$ V, n
    if energy > 50 [! `1 i# @) A2 t8 @$ v4 _+ t7 Y/ v
      set energy energy - 50; q! P, L$ T' O' X
      hatch 1 [ set energy 50 ]+ W/ x5 ?" S/ Q# a1 L$ x4 B
      ]
6 l" ]4 w% W1 o9 Q% d    ]( p  q" g- @0 @$ R. ?
end
6 t2 G; t) N4 c- j, sto check-death
2 i, Y& t: s1 g8 x0 {  ask turtles [# i6 R% }  ~" L
    if energy <= 0 [ die ]5 D3 p! |8 h& F$ m: i
    ]
7 Z8 r- h: D5 y* {- Vend
' K2 r. Q- q* R0 D5 A4 Lto regrow-grass0 _! Z6 V( s5 Z  N
  ask patches [# S% C: |1 f& b6 r! M% a+ V
    if random 100 < 3 [ set pcolor green ]
+ u  k% o* D7 I0 z, L    ]  [5 y& J( ^5 d( e& D$ C. a9 \
end
( `- i& a/ K" p7 yto do-plots
7 C3 D( K0 \/ A. N5 F  set-current-plot "Totals"- q. K4 }) n+ [5 \. {
  set-current-plot-pen "turtles"  @) c; r9 B; q4 c& @+ H
  plot count turtles' V$ @+ Y7 h; c0 Z. I7 t0 [
  set-current-plot-pen "grass"2 m# B: F5 c9 k, I( z2 ^
  plot count patches with [pcolor = green]3 k% D6 m- V2 C% n
end) L  y% E2 @7 q' y& j7 _5 h: V
可是运行时提示no such plot: "Totals"
, g' O4 @: v. g# ]error while observer running SET-CURRENT-PLOT
% n5 |. v+ g/ n7 s+ h  called by procedure DO-PLOTS
$ y- T! g* L& w" k9 [! b8 j, C" @  called by procedure SETUP
6 d$ V9 p! K2 j4 ~& r6 X% b; ?8 x  called by 按钮 'setup'
! t" i* |7 x% V1 @求大神解答啊
发表于 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
2 i7 F# y" a  p$ G( N2 \% U建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-2-26 17:49 , Processed in 0.017086 second(s), 17 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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