设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9901|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]
) y6 m6 E# |$ L2 mto setup: k4 p9 ]; \; _: ]4 o; W
  clear-all
8 ?  b+ r) i% f6 Y) W& x  setup-patches
2 ]- k5 `: E& r- j( W1 S  create-turtles 100+ R% c# x: `" N1 h: l  s
  do-plots5 y$ U; p' j4 l' V
  ask turtles [ setxy random-xcor random-ycor ]* p% v) `( X" l2 e: |0 A
end
3 q" h) ]6 ?) [6 h5 j+ uto go
& ?1 v& B+ F# B1 l/ Y/ Q3 S  move-turtles
7 O1 z9 O1 X" L3 [( h7 P* x" d* a  eat-grass5 _) j- e) P9 y2 }
  reproduce; O% |# u' z( f8 [+ V3 J
  check-death
: Y! p9 s6 W3 c7 y' O; g$ M  regrow-grass& Y- z" g* u9 m
  do-plots8 r% i& t2 [+ h% o: f3 I
end- q' d( x4 q) `0 `& I0 S4 e! y
to move-turtles: r' y% k) }: _# \) j! @8 G. \8 E
  ask turtles [: b- I( k; ]. P( t9 J4 {
    right random 360
  N% F7 B5 r; \: X8 H+ s' m    forward 1
7 v2 [' ]* J. I' D( J; I, v    set energy energy - 1
: k8 `: H, L' V0 ^) R    ]
  T6 P% E% V+ x9 o& Bend$ V1 |# {6 t7 K  s* T1 W4 C
to setup-patches# T- P) k; B. z! B. G. e, F
  ask patches [ set pcolor green ]
: o2 G5 {/ g- G8 i$ z; M5 D3 o6 Vend$ G! T) m' m6 a. N
to setup-turtles; Q, d; y8 }1 R7 F1 m- `
  create-turtles 100; z& s# F8 r$ P9 Z7 i7 U% ?
  ask turtles [ setxy random-xcor random-ycor ]
, Z: W" \' k: Hend- @1 R9 {0 }# o: o5 D2 ?
to eat-grass
& s0 m! Y1 J& s/ `  ask turtles [
, ~8 k4 F# h% r1 Z6 o0 o    if pcolor = green [
! o/ [( O/ P' p) L      set pcolor black
4 N! f2 e' X+ Q/ P! p2 {      set energy (energy + 10)9 _. J+ y" u7 t7 E% ~8 w
      ]
' P' W  P2 A+ e1 b- x    ifelse show-energy?
6 ]3 f2 Y2 M4 N      [ set label energy ]
: `( O3 V3 ^3 o# C0 w& N      [ set label "" ]
# c3 ^  {7 S- [4 f# C    ]- M: d  k( v( d5 L; F2 c
end+ ?2 U% f( Z3 N6 e
to reproduce
; `; W# v$ u: I6 Y: k  ask turtles [
4 B. J7 F' e. S$ C0 G3 F+ Y, b4 }    if energy > 50 [) k  O& @% L' J- R" d
      set energy energy - 506 k% h# o% C% ~9 u( B
      hatch 1 [ set energy 50 ]9 K) i# R& c* d! K1 Z
      ]
1 a! V- j+ ~) T. Y) [+ Z    ]
+ r( b6 r- L+ s1 w+ Gend+ T9 Y1 X% L' F$ j
to check-death
' [8 r7 C4 g$ w* @5 `$ v( h9 h% {  Q% B0 u  ask turtles [
: a' H# D; t/ n6 j* E% ~2 R2 a    if energy <= 0 [ die ]
! P" R9 Q* o/ U8 y    ]( Q8 o8 l/ @: e: c! n, W4 @
end7 k# w+ i( E0 {1 t) f: j4 ]
to regrow-grass
8 {1 T2 y) |5 r3 O  ask patches [
* g# T3 l% e( [- h    if random 100 < 3 [ set pcolor green ]
) ?  d* _( l/ e) v; B    ]
4 n3 a, t! H9 J0 S! Bend" Z+ Q  e& {/ l4 `. U
to do-plots& f/ a1 y- Z+ ?# [3 ^) b
  set-current-plot "Totals"
; F: ~8 Y' O: t8 o. L' Q/ I( V  set-current-plot-pen "turtles"
, y/ r- |* s) j9 ^6 n$ B  plot count turtles# _# s6 {- p! g
  set-current-plot-pen "grass"
- z! }% {2 f. K  plot count patches with [pcolor = green]
* a% E, Q, b3 m7 R9 u  \end  y! W: b& ?& _, e8 x/ F
可是运行时提示no such plot: "Totals"" C, Z) H1 y, N9 R
error while observer running SET-CURRENT-PLOT
' A. w; {6 A' [  called by procedure DO-PLOTS$ T) d+ a% n" \4 R
  called by procedure SETUP
2 m/ q- `; }7 R# ^  called by 按钮 'setup'
# L8 O; {, x; e+ J2 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 5 g1 f  N' E! e, e1 e# u
建一个叫做叫做Totals的绘图框就行了

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

本版积分规则

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

GMT+8, 2026-1-29 14:27 , Processed in 0.018206 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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