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

📄 abstractfirebrigadeagent.java.bak2

📁 2004年robotcup世界冠军源代码
💻 BAK2
字号:
// Copyright (C) 2002 Takeshi Morimoto <morimoto@takopen.cs.uec.ac.jp>// All rights reserved.package yab.agent;import java.net.*;import java.util.*;import yab.agent.*;import yab.agent.object.*;import yab.io.NozzleElement;import yab.io.ProtocolConstants;public abstract class AbstractFireBrigadeAgent extends PlatoonAgent {  protected AbstractFireBrigadeAgent(InetAddress address, int port) {    super(ProtocolConstants.AGENT_TYPE_FIRE_BRIGADE, address, port);  }  protected int lastTarget = 0;  private int timeOut = 0;  protected double amountOfWater = 0.0;  protected FireBrigade self() {return (FireBrigade) world.self;  }  /** @param targets each element of the given <code>targets</code>   *  must be a burning building.   */  protected void extinguish(ArrayList targets) throws ActionCommandException {    extinguish((Building[]) targets.toArray(new Building[0]));  }  protected void extinguish(Building target) throws ActionCommandException {    extinguish(new Building[] {target});  }  protected void extinguish(Building[] targets) throws ActionCommandException {    MotionlessObject pos = self().motionlessPosition();    NozzleElement[] nozzles = new NozzleElement[targets.length];    for (int i = 0; i < nozzles.length; i++) {      Building fire = targets[i];      if (self().distance(fire) > EXTINGUISHABLE_DISTANCE) {        throw new Error(self() + " cannot extinguish a far building.");      }      if (lastTarget == fire.id) {        ++timeOut;        Building target = (Building)world.get(fire.id);        if(target.isBurning()){          ++amountOfWater;        }      } else {        timeOut = 0;        amountOfWater = 0.0;      }      nozzles[i] = new NozzleElement(fire.id,                                     self().direction(fire),                                     pos.x(),                                     pos.y(),                                     EXTINGUISHABLE_QUANTITY                                     / targets.length);    }    extinguish(nozzles);  }  protected void extinguish(NozzleElement[] targets) throws      ActionCommandException {    moveAct = false;    acted =true;    extinguishAct = true;    socket().akExtinguish(self().id, targets);    throw new ActionCommandException();  }  protected boolean timeoutLimit() {    return (timeOut == 2);  }}

⌨️ 快捷键说明

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