设为首页收藏本站

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

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11912|回复: 4

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

  [复制链接]
 楼主| 发表于 2013-4-5 21:09:10 | 显示全部楼层 |阅读模式
我编的程序如下turtles-own [energy]2 k  Y0 [  H3 D! l
to setup- Q* v# n7 l7 u8 v* }. Y5 j
  clear-all- L% A* `1 D1 E, h
  setup-patches0 T0 K: ]5 J2 n
  create-turtles 100% V/ W& s8 h) R( H3 [3 V* ?
  do-plots
0 L6 g$ `0 _' K9 q  ask turtles [ setxy random-xcor random-ycor ]
1 |2 W, G! l1 L9 t# @$ A" ^end
/ W' [; o$ Y3 L+ F9 ^0 R1 d2 ]to go
8 J9 ?% q8 m8 v# J& N5 j1 T3 J# l  move-turtles
9 t. ^8 h- X" g7 z0 a  eat-grass
) ^7 ^: d$ k1 |2 z) X  R' s  reproduce
* l% ]# a9 j7 q+ i# j" M  check-death
1 i* Q9 `/ O5 C" m2 ^+ O  regrow-grass
% ^1 B/ A) m+ f/ n  do-plots
+ v5 D/ w1 A: V8 |. Z) e3 s$ Gend
! j0 I8 ]$ L/ pto move-turtles9 L# F! O  B# z
  ask turtles [
% J% B6 O! v1 }/ u2 V. y    right random 360
3 S9 ^9 ?& ^& f2 ?. b, c    forward 1
+ B7 T: }9 y& q2 I2 U( b5 I$ U2 X    set energy energy - 1& P$ F% B; U, V* e$ |" @/ ^( C' A
    ]: ]+ y& W$ C3 J
end1 w  v( Z/ v' }& r
to setup-patches
+ m5 o5 W& z2 P0 s8 X; |' c  ask patches [ set pcolor green ]
: ^9 e: \1 v! D" L) z- l1 k2 Rend
/ u6 [% R* d/ V( L$ G' eto setup-turtles& {0 ]& V2 U) H8 F; s
  create-turtles 100
9 m$ {. Y& T- ]5 Y, ^6 R  ask turtles [ setxy random-xcor random-ycor ]
$ n6 n6 F# m2 z3 n4 i" Cend
1 Y4 N- a" t, _" zto eat-grass* \2 w8 S4 y0 L( i+ ?3 b
  ask turtles [& W% Z* ^% u9 ]$ j9 X- G
    if pcolor = green [0 C. M' Y1 ]9 w0 v* t8 \
      set pcolor black/ z: P, _! E# T; C* w
      set energy (energy + 10)2 c! w! C6 s' G2 x9 `; x, J( \
      ]9 p9 g0 v8 Y) |* a( x0 U
    ifelse show-energy?( J; r1 r* z4 `4 C* W2 v
      [ set label energy ]
4 S; x3 l; W: m6 p      [ set label "" ]
; h8 j, M$ y1 H2 ~( w. R3 p9 D    ]
3 o; T4 E9 I+ S% V. T9 V% Hend
$ W& R  M- T- D+ ?- s4 ]to reproduce
3 H; r* E/ j6 n2 A2 a4 m; k; Y  ask turtles [( W$ g. N( o* U4 {
    if energy > 50 [
6 u9 c4 y0 K5 E' o      set energy energy - 50
0 ?" o1 _8 @9 k- @+ B7 b      hatch 1 [ set energy 50 ]! F6 I$ G' P8 E: M$ `
      ]
0 y' i0 Z4 P  f+ N: y# v  X9 v    ]- d8 f. c5 ]* ~1 _$ b& p
end/ \# ?4 F' E' h
to check-death
9 O7 Z3 ~1 [& ?$ ]  ask turtles [% m, e1 G8 J# R) q
    if energy <= 0 [ die ]
' l) b& y9 }" I$ Q    ]) a$ r! N" I! O
end- u5 Q/ I$ i4 R8 ?
to regrow-grass
$ s/ Q  J) y# c1 S+ j  ask patches [
5 ^+ _1 {; f- w' M9 e9 g! n4 m    if random 100 < 3 [ set pcolor green ]
( O) L" a9 O# I! j4 c! M! [    ]
. H. b8 i5 K& L! u$ vend
: H* z  `+ \6 a* t! g" Zto do-plots
9 ?  ]- _# |5 p  set-current-plot "Totals"8 C8 @, O" _, _. a5 ]4 J% K. f
  set-current-plot-pen "turtles"7 y9 W; i5 X& }) N/ @/ M* Z' W
  plot count turtles3 f! R' C6 j7 b0 K: c# ?
  set-current-plot-pen "grass"& t. K/ n, A+ p+ C
  plot count patches with [pcolor = green]- c, U6 M' Q3 v; [' C' h
end  f2 x( V) X# c7 {) B
可是运行时提示no such plot: "Totals"
( ?+ B0 j- X: `4 b4 Verror while observer running SET-CURRENT-PLOT
5 x$ h2 q3 `6 S$ [# D  called by procedure DO-PLOTS  S- D5 M- A. a) ]0 f! U
  called by procedure SETUP0 d# j: ?  l$ B# n# G2 f1 o1 v
  called by 按钮 'setup'0 N* {0 ?. R0 Q% r( n5 R" h0 Y# 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
8 E/ _8 G4 P) \) |. l1 t建一个叫做叫做Totals的绘图框就行了
' e! q( @7 M: ?2 n2 J
哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈
发表于 2016-5-3 09:17:18 | 显示全部楼层
你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-7-11 01:22 , Processed in 0.015319 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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