newlove 发表于 2013-4-5 21:09:10

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

我编的程序如下turtles-own
to setup
clear-all
setup-patches
create-turtles 100
do-plots
ask turtles [ setxy random-xcor random-ycor ]
end
to go
move-turtles
eat-grass
reproduce
check-death
regrow-grass
do-plots
end
to move-turtles
ask turtles [
    right random 360
    forward 1
    set energy energy - 1
    ]
end
to setup-patches
ask patches [ set pcolor green ]
end
to setup-turtles
create-turtles 100
ask turtles [ setxy random-xcor random-ycor ]
end
to eat-grass
ask turtles [
    if pcolor = green [
      set pcolor black
      set energy (energy + 10)
      ]
    ifelse show-energy?
      [ set label energy ]
      [ set label "" ]
    ]
end
to reproduce
ask turtles [
    if energy > 50 [
      set energy energy - 50
      hatch 1 [ set energy 50 ]
      ]
    ]
end
to check-death
ask turtles [
    if energy <= 0 [ die ]
    ]
end
to regrow-grass
ask patches [
    if random 100 < 3 [ set pcolor green ]
    ]
end
to do-plots
set-current-plot "Totals"
set-current-plot-pen "turtles"
plot count turtles
set-current-plot-pen "grass"
plot count patches with
end
可是运行时提示no such plot: "Totals"
error while observer running SET-CURRENT-PLOT
called by procedure DO-PLOTS
called by procedure SETUP
called by 按钮 'setup'
求大神解答啊

emlyn 发表于 2013-5-29 00:25:38

no such plot: "Totals",就是说你的界面里没有叫做Totals的绘图框

emlyn 发表于 2013-5-29 00:26:26

建一个叫做叫做Totals的绘图框就行了

newlove 发表于 2013-6-4 12:24:45

emlyn 发表于 2013-5-29 00:26 static/image/common/back.gif
建一个叫做叫做Totals的绘图框就行了

哦,知道了,虽然自己应经找到问题了,不过还是谢谢哈

pichan 发表于 2016-5-3 09:17:18

你也可以直接再界面页创建“绘图”,然后设置时钟(ticks),每一步画一次,不用自己操心。
页: [1]
查看完整版本: 自学中文手册时遇到了问题,求高手解答