设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 12741|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]' A2 C" C  L. y2 J$ b  l
to setup9 i4 R  ]1 V1 }- J, n
  clear-all/ g! Z" l& p; {: F, Q. {# R; k
  setup-patches$ R0 ^. y. o; L. m6 p( E
  create-turtles 1002 C  \. A: p9 m$ d% W, Y. v+ u$ _
  do-plots9 U; l  R( h2 F9 F* U# t0 {
  ask turtles [ setxy random-xcor random-ycor ]$ l! g8 w$ _% n- [8 }) p
end! c2 Q5 H6 T& l8 v6 N( B* G
to go# z5 D5 h& U8 a% o
  move-turtles* ^. V; M' [. S/ m
  eat-grass
; v+ u+ p% u* A  reproduce6 m* W4 {# X6 c/ L! h, f; ]8 ~
  check-death
- L$ |* P) X# g7 l# X# x0 {9 `  regrow-grass" z' P1 K, }+ \$ Q; w% y2 q
  do-plots
& r2 W/ y: q7 x" i* F- mend( z, ^2 z" a, `4 O' S* j1 F
to move-turtles- X' [  d6 |& k' \
  ask turtles [3 }4 _- T6 I9 f9 O9 p
    right random 360
1 I7 |/ K/ J- A1 {' U8 n3 M4 x, G    forward 1
! j: P8 L/ n3 R    set energy energy - 12 R  |0 q, N6 i# @
    ]& d6 [. X% ?) [* X8 O, C
end
% T! l. C' |) I/ q" u% Wto setup-patches1 i" j3 \* r; S# @* A
  ask patches [ set pcolor green ]4 B$ y2 {; l" z  ?  u( G
end- o/ o" m6 ~3 V- C- d1 [
to setup-turtles
4 ]7 [6 c# c2 t* y+ z; v- B% @  create-turtles 100
% a0 c! j/ M7 X$ |6 }! a/ h  ask turtles [ setxy random-xcor random-ycor ]4 l0 t: q" i; j, l
end. K4 O* \* R& \" ?) c2 q" Z3 ~$ u
to eat-grass8 P4 l( X# x/ B4 x8 |0 W5 X
  ask turtles [
. K  e+ U5 L# V3 s    if pcolor = green [5 f+ Z# X' d" s; v  c- [' C
      set pcolor black
; m+ H4 q7 J/ P$ g6 s      set energy (energy + 10)
# R, L( H* d0 f( W0 M: M/ g8 a      ]
  [* J/ l" ]9 P4 z( U( f    ifelse show-energy?" _% j1 I' ^- |0 R5 k  J2 F$ V! g
      [ set label energy ]
% Y; }( k3 _5 C# t* y' T      [ set label "" ]% a) I& ~' s5 ?2 J' K" l+ L
    ]
1 P( B3 m7 y, K* Qend% [0 e% ?8 @5 e: |% s6 M) \' x
to reproduce
+ J0 h  B2 t* U$ {/ J  ask turtles [! @, F* a2 S* h& J3 e8 B/ c) Z0 u
    if energy > 50 [# s, ]8 M6 Z+ S- O2 l
      set energy energy - 50
" t5 c& \. ?# ]+ d' P. o      hatch 1 [ set energy 50 ]- |! a' Q" i5 m" q2 a
      ]
2 Y! [) L: S1 R& |, G$ k) d    ]' _9 Y0 n* B! |9 F  V1 u& b
end7 P% I& D$ Y) e
to check-death
. d, g2 a% l: D& i& }  _. K  ask turtles [
9 m% x' u9 u1 K9 Y* v: {) A    if energy <= 0 [ die ]
6 {/ _' }; y" h3 R! k    ]. J' u+ O5 K: X7 c! U
end4 D# ]. K2 N" N7 ]
to regrow-grass$ Q4 O# U* N# y2 a; m+ z4 y. r( M: ]4 \
  ask patches [
# n6 S* a5 H! f3 r3 A7 o    if random 100 < 3 [ set pcolor green ]6 o$ u8 {9 r9 E/ ]! X4 X/ |- h
    ]: g2 E' D' u, F5 [; L
end2 L# I4 l5 Y8 O& Y5 H! r. N' ?
to do-plots$ S4 M9 {$ C/ A
  set-current-plot "Totals"
: }0 C: r; }+ Y9 f+ D/ k  set-current-plot-pen "turtles"
, i* ^! Z" w6 z5 g  plot count turtles% N8 p6 u) y4 T! s
  set-current-plot-pen "grass", }0 k- s/ V  z# |- A9 ~
  plot count patches with [pcolor = green]# y4 E  C* n( P: p: F9 V" i3 r9 n
end
8 s2 d1 P* I' C0 p& z0 e可是运行时提示no such plot: "Totals"
2 q* n5 |5 x( i# f7 `error while observer running SET-CURRENT-PLOT
2 P' t& `: M( ~  called by procedure DO-PLOTS" V8 t" ?2 _2 r2 K8 h! e' N
  called by procedure SETUP
  \1 \4 L& K7 K& u3 }. D  called by 按钮 'setup'5 }$ Q4 `1 {+ k! P7 o
求大神解答啊
发表于 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
1 Y# \' `7 m4 z建一个叫做叫做Totals的绘图框就行了
9 W7 V! |- y% p/ g
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-9-13 22:38 , Processed in 0.015811 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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