realobject.java

来自「2004年robotcup世界冠军源代码」· Java 代码 · 共 59 行

JAVA
59
字号
// Copyright (C) 2002 Takeshi Morimoto <morimoto@takopen.cs.uec.ac.jp>// All rights reserved.// Edited By Omid Aghazadehpackage yab.agent.object;import yab.agent.*;import yab.io.object.*;import java.util.*;import MRL.Utilities.Partitioning.*;public abstract class RealObject extends RCRObject {    public RealObject(int id, BaseRealObject object,                      DisasterSpace world) { super(id, object, world); }  //saeed 85-2-3    public abstract int x();    public abstract int y();    public abstract MotionlessObject motionlessPosition();    public boolean hasBeenSeen() { // Since time() Is The Time Of Last Seeing , This Method Is Correct        return time() >= Constants.TIME_STARTING_ACTION;    }    public int distance(RealObject to) { return Util.distance(this, to); }    public int direction(RealObject to) { return Util.direction(this, to); }    public String toString(){      return super.toString();//+",Position:[" + x() +","+y()+"]";    }    public final Property distancePrp = new Property(){      public Object eval(Object obj) {        if(obj instanceof RealObject) return new Integer(distance((RealObject)obj));        else if (obj instanceof Partitionable) {          Partitionable p = (Partitionable) obj;          return new Integer(Util.distance(x(),y(),p.x(),p.y()));        }        else throw new Error("WHA!");      }    };    public int getMinDist(Collection col) {      RealObject ro;      int bestmatch = Integer.MAX_VALUE, dist;      for (Iterator it = col.iterator(); it.hasNext(); ) {        ro = (RealObject) it.next();        dist = distance(ro);        if (dist < bestmatch) {          bestmatch = dist;        }      }      return bestmatch;    }    public Report report = new Report();}

⌨️ 快捷键说明

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