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

📄 humanoidagent.java

📁 2004年robotcup世界冠军源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
          if(rd.linesToTail()<=0) return notPassable;      }      else if(rd.tail()==(PointObject) from)      {          if(rd.linesToHead()<=0) return notPassable;      }      else      {            System.err.println(" Error in police_cost_function_move");      }        if(!rd.hasBeenSeen()){            Path cpath = world.getCurrentPath();            if(cpath != null){                if(cpath.contains(rd)){                    int timeInPath = self().getCyclesHaveBeenInPath(cpath,true);                    timeInPath -= MRL.Police.PoliceConstantsAndConditions.CYCLES_TO_IGNORE_IF_WERE_IN_PATH_FOR_COST_FUNCTION;                    if(timeInPath < 1)                        timeInPath = 1;                    c*= Math.pow(notSeenCoef, timeInPath);                }            }            c*=notSeenC;        }        else if(rd.passableLinesFrom((PointObject)from)==0) c=hasBlocksC;        if (trafficSet.contains(rd))        {            /*            int count=0;            int [] ph ;            while((ph= self().getPositionHistory(time()-count)) != null && ph.length==1)            {                if( time()>count)                {                    count++;                    c*= trafficCOEF;                    if(MRL.MRLConstants.ROUTING_DEBUG_MODE) System.out.println( " Self id" + self().id + " count" + count + " Time " + time() + " ID motionless possition" + self().getPositionHistory(time())[0]+ " To ID" +to );                }                else break;            }            count=0;            if(!(self().motionlessPosition() instanceof Building)){                while((ph=self().getPositionHistory(time()-count)) ==null || ph.length==0 )                {                    if( time()>count)                    {                        count++;                        c*= trafficCOEF;                        if(MRL.MRLConstants.ROUTING_DEBUG_MODE) System.out.println( " Self id" + self().id + " count" + count + " Time " + time() + " No Position" );                    }                    else break;                }            }            */            // SHAYAD Ye Police Yek Cycle Yekja Act Submit Karde Bashe Va PH Esh 0 Bashe , Va Oonam Jozve Traffic Hesab Mishe , Daghigh Nist .//            c*=trafficC;                int stuckCycles =self().getStuckCycles() , timeInPath , res;                Path cPath = world.getCurrentPath();                if(cPath != null){                    timeInPath = self().getCyclesHaveBeenInPath(cPath,true);                    res = Util.max(stuckCycles,timeInPath);                    c*= Math.pow(trafficCoef,res);                }                else                    c*= Math.pow(trafficCoef,stuckCycles);        }        c*= rd.length();      return c;    }  };  public static final Router.CostFunction CLEARING_COST_FUNCTION // Connected Roads Ro Vardashtam!      = new Router.CostFunction() {        final float WEIGHT = Integer.MAX_VALUE;        final float notPassableC = WEIGHT;    public float cost(MotionlessObject from, MotionlessObject to) {      float c = 1f;      if (! (to instanceof Road))      {          if(to instanceof Node)          {              if(from instanceof Road)              {                  if(to==(((Road)from).head()) && ((Road)from).linesToHead()<=0)                    return notPassableC;                  else if(to==(((Road)from).tail()) && ((Road)from).linesToTail()<=0 )                    return notPassableC;              }          }          return c;      }      Road rd = (Road) to;      if(rd.head()==(PointObject) from)      {          if(rd.linesToHead()<=0) return notPassableC;      }      else if(rd.tail()==(PointObject) from)      {          if(rd.linesToTail()<=0) return notPassableC;      }      else      {            System.out.println(" Error in police_cost_function_move");      }      c*= rd.length();      return c;    }  };    public final Router.CostFunction MOVING_COST_FUNCTION = new Router.CostFunction(){        final boolean isPolice = world.self instanceof PoliceForce;        public float cost(MotionlessObject from, MotionlessObject to) {            if(isPolice){                return POLICE_COST_FUNCTION_MOVE.cost(from,to);            }            else{                return TRAFFIC_MOVING_COST_FUNCTION.cost(from,to);            }        }    };     //not check for cycle in trrafic    public final Router.CostFunction TRAFFIC_MOVING_COST_FUNCTION      = new Router.CostFunction() {       final float WEIGHT = (float) Integer.MAX_VALUE;        final float trafficC = 10f;        final float notSeenC = 3f;        final float notPassableC = WEIGHT;        final float oneWayNotSeenC = WEIGHT/2;        final float oneWayHasBlocksC = WEIGHT;        final float hasBlocksC = WEIGHT;        final Set trafficSet = world.inTraffic;        final boolean bpol = world.self instanceof PoliceForce;    public float cost(MotionlessObject from, MotionlessObject to) {      float c = 1;      if (! (to instanceof Road))      {          if(to instanceof Node)          {              if(from instanceof Road)              {                  if(to==(((Road)from).head()) && ((Road)from).linesToHead()<=0)                  {                    return notPassableC;                  }                  else if(to==(((Road)from).tail()) && ((Road)from).linesToTail()<=0 )                  {                    return notPassableC;                  }                  else if(((Road)from).linesToHead()<=0 || ((Road)from).linesToTail()<=0)                  {                    if (!((Road)from).hasBeenSeen())                        return oneWayNotSeenC;                    else if (((Road)from).passableLinesTo((PointObject)to) <= 0)                        return oneWayHasBlocksC;                  }              }          }          return c;      }      Road rd = (Road) to;      if(rd.head()==(PointObject) from)      {          if(rd.linesToTail()<=0) return notPassableC;          else if (rd.linesToHead()<=0)          {              if (!(rd.hasBeenSeen()))                 return oneWayNotSeenC;              else if(rd.passableLinesFrom((PointObject)from) <=0)                 return oneWayHasBlocksC;          }      }      else if(rd.tail()==(PointObject) from)      {          if(rd.linesToHead()<=0) return notPassableC;          else if (rd.linesToTail()<=0)          {              if (!(rd.hasBeenSeen()))                 return oneWayNotSeenC;              else if(rd.passableLinesFrom((PointObject)from) <=0)                 return oneWayHasBlocksC;          }      }      c*= rd.length();      if(NOT_PASSABLE_C.eval(rd)) //rd.passableLinesFrom((PointObject)from) == 0        return c*hasBlocksC;      if(trafficSet.contains(rd)) {//        return c*trafficC;           int stuckCycles =self().getStuckCycles() , timeInPath , res;                Path cPath = world.getCurrentPath();                if(cPath != null){                    timeInPath = self().getCyclesHaveBeenInPath(cPath,false);                    res = Util.max(stuckCycles,timeInPath);                    c*= Math.pow(trafficC,res);                }                else                    c*= Math.pow(trafficC,stuckCycles);//          return  c* (float)Math.pow(trafficC , self().getStuckCycles());      }      if(rd.hasBeenSeen()) return c;      return c * notSeenC  ;    }  };        public Route getRouteFromCurrentPos(Collection destinations,Router.CostFunction cf){        MotionlessObject pos = self().motionlessPosition();        Route res;        if (! (pos instanceof Road) ||PASSABLE_C.eval(pos)){ // POS //  ( (Road) pos).passableLines() >= 1          res = Router.get(pos, destinations, cf);        }        else{ // OP          res = Router.get(outsidePosition(), destinations, cf);        }        modifyOriginToCurrentPosition(res);        return res;    }    public Route getRouteFromCurrentPos(MotionlessObject mo,Router.CostFunction cf){        return getRouteFromCurrentPos(Collections.singleton(mo),cf);    }}

⌨️ 快捷键说明

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