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

📄 tutorial3.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.app.tutorial3;import sim.engine.*;import sim.field.grid.*;import sim.util.*;import ec.util.*;public class Tutorial3 extends SimState    {    public DoubleGrid2D trails;    public SparseGrid2D particles;        public int gridWidth = 100;    public int gridHeight = 100;    public int numParticles = 500;        public Tutorial3(long seed)        {        super(new MersenneTwisterFast(seed), new Schedule(3));        }    public void start()        {        super.start();        trails = new DoubleGrid2D(gridWidth, gridHeight);        particles = new SparseGrid2D(gridWidth, gridHeight);                Particle p;                for(int i=0 ; i<numParticles ; i++)            {            p = new Particle(random.nextInt(3) - 1, random.nextInt(3) - 1);  // random direction            schedule.scheduleRepeating(p);            particles.setObjectLocation(p,                                        new Int2D(random.nextInt(gridWidth),random.nextInt(gridHeight)));  // random location            }                // Schedule the decreaser        Steppable decreaser = new Steppable()            {            public void step(SimState state)                {                // decrease the trails                trails.multiply(0.9);                }            static final long serialVersionUID = 6330208160095250478L;            };                    schedule.scheduleRepeating(Schedule.EPOCH,2,decreaser,1);        }    public static void main(String[] args)        {        doLoop(Tutorial3.class, args);        System.exit(0);        }        static final long serialVersionUID = 9115981605874680023L;        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -