⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tutorial7.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 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 + -