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

📄 agent.java

📁 MASON代表多主体邻里或网络仿真(Multi-Agent Simulator of Neighborhoods or Networks)。它是乔治梅森大学用Java开发的离散事件多主体仿真核心库
💻 JAVA
字号:
package sim.app.virus;import sim.engine.*;import sim.util.Double2D;import sim.portrayal.*;import java.awt.geom.*;public abstract /*strictfp*/ class Agent extends SimplePortrayal2D implements Steppable    {    public String id;    public Double2D agentLocation;     public int intID = -1;    public Agent( String id, Double2D location )        {        this.id = id;        this.agentLocation = location;        }    double distanceSquared( final Double2D loc1, Double2D loc2 )        {        return( (loc1.x-loc2.x)*(loc1.x-loc2.x)+(loc1.y-loc2.y)*(loc1.y-loc2.y) );        }    // Returns "Human", "Evil", or "Good"    public abstract String getType();      public boolean hitObject(Object object, DrawInfo2D info)        {        double diamx = info.draw.width*VirusInfectionDemo.DIAMETER;        double diamy = info.draw.height*VirusInfectionDemo.DIAMETER;        Ellipse2D.Double ellipse = new Ellipse2D.Double( (int)(info.draw.x-diamx/2),(int)(info.draw.y-diamy/2),(int)(diamx),(int)(diamy) );        return ( ellipse.intersects( info.clip.x, info.clip.y, info.clip.width, info.clip.height ) );        }    }

⌨️ 快捷键说明

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