📄 tutorial7.java
字号:
package sim.app.tutorial7;import sim.engine.*;import sim.field.grid.*;import ec.util.*;public class Tutorial7 extends SimState { public SparseGrid3D flies; public DoubleGrid2D xProjection; public DoubleGrid2D yProjection; public DoubleGrid2D zProjection; int width = 30; int height = 30; int length = 30; public void setWidth(int val) { if (val > 0) width = val; } public int getWidth() { return width; } public void setHeight(int val) { if (val > 0) height = val; } public int getHeight() { return height; } public void setLength(int val) { if (val > 0) length = val; } public int getLength() { return length; } public Tutorial7(long seed) { // two orders super(new MersenneTwisterFast(seed), new Schedule(2)); } public void start() { super.start(); flies = new SparseGrid3D(width,height,length); xProjection = new DoubleGrid2D(height,length); yProjection = new DoubleGrid2D(width,length); zProjection = new DoubleGrid2D(width,height); // schedule the zero-er at ordering 0 schedule.scheduleRepeating(new Steppable() { public void step(SimState state) { xProjection.setTo(0); yProjection.setTo(0); zProjection.setTo(0); } // because I am an anonymous nested subclass (see Tutorial 3)... static final long serialVersionUID = -4596371762755892330L; }); // make some random flies at ordering 1 for(int i=0; i<100;i++) { Fly fly = new Fly(); flies.setObjectLocation(fly, random.nextInt(width), random.nextInt(height), random.nextInt(length)); schedule.scheduleRepeating(Schedule.EPOCH,1,fly,1); } } public static void main(String[] args) { doLoop(Tutorial7.class, args); System.exit(0); } // because I have an anonymous nested subclass (see Tutorial 3)... static final long serialVersionUID = -7776187839992045098L; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -