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

📄 keepawaywithui.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.app.keepaway;import sim.engine.*;import sim.display.*;import sim.portrayal.continuous.*;import java.awt.*;import javax.swing.*;public class KeepawayWithUI extends GUIState    {    public Display2D display;    public JFrame displayFrame;    ContinuousPortrayal2D entityPortrayal = new ContinuousPortrayal2D();    public static void main(String[] args)        {        KeepawayWithUI botball = new KeepawayWithUI();        Console c = new Console(botball);        c.setVisible(true);        }        public KeepawayWithUI() { super(new Keepaway(System.currentTimeMillis())); }        public KeepawayWithUI(SimState state) { super(state); }        public String getName() { return "Keepaway"; }        public String getInfo()        {                Keepaway bb = (Keepaway) state;                return             "<H2>Keepaway</H2><br>"+            "A misleadingly-named Keepaway Soccer Demo<br>"+            "by Dan Kuebrich<br><br>";         }        public void start()        {        super.start();        // set up our portrayals        setupPortrayals();        }        public void load(SimState state)        {        super.load(state);        // we now have new grids.  Set up the portrayals to reflect that        setupPortrayals();        }            public void setupPortrayals()        {        // tell the portrayals what to portray and how to portray them        entityPortrayal.setField(((Keepaway)state).fieldEnvironment);        entityPortrayal.setPortrayalForClass(Bot.class, new sim.portrayal.simple.RectanglePortrayal2D(Color.red));        entityPortrayal.setPortrayalForClass(Ball.class, new sim.portrayal.simple.OvalPortrayal2D(Color.white));                            // reschedule the displayer        display.reset();                        // redraw the display        display.repaint();        }        public void init(Controller c)        {        super.init(c);                // Make the Display2D.  We'll have it display stuff later.        display = new Display2D(400,400,this,1); // at 400x400, we've got 4x4 per array position        displayFrame = display.createFrame();        c.registerFrame(displayFrame);   // register the frame so it appears in the "Display" list        displayFrame.setVisible(true);        // attach the portrayals        display.attach(entityPortrayal,"Bots and Balls");        // specify the backdrop color  -- what gets painted behind the displays        display.setBackdrop(new Color(0,80,0));  // a dark green        }            public void quit()        {        super.quit();                if (displayFrame!=null) displayFrame.dispose();        displayFrame = null;  // let gc        display = null;       // let gc        }    }                    

⌨️ 快捷键说明

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