private void checkAlakiStock(Path path) throws SOSActionException { log().info("checking alaki stock"); CycleInformations cycleinfo1 = me.informationStacker.getInformations(1); CycleInformations cycleinfo2 = me.informationStacker.getInformations(2); CycleInformations cycleinfo3 = me.informationStacker.getInformations(3); // Move Stock Move Stock Stock Stock log().trace("cycleinfo1:" + cycleinfo1); log().trace("cycleinfo2:" + cycleinfo2); log().trace("cycleinfo3:" + cycleinfo3); if (!(cycleinfo1.getAct() instanceof MoveAction) || cycleinfo1.getAct() instanceof StockMoveAction) return; if ( /* !(cycleinfo2.getAct() instanceof MoveAction) || */ !(cycleinfo2.getAct() instanceof StockMoveAction)) return; if (!(cycleinfo3.getAct() instanceof MoveAction) || cycleinfo3.getAct() instanceof StockMoveAction) return; log() .debug( "cycleinfo1:" + cycleinfo1.getPositionPair() + "cycleinfo2:" + cycleinfo2.getPositionPair() + " cycleinfo3:" + cycleinfo3.getPositionPair()); if (SOSGeometryTools.getDistance( cycleinfo1.getPositionPair().second(), cycleinfo2.getPositionPair().second()) < MoveConstants.TRAFFIC_CHECKING_DISTANCE && SOSGeometryTools.getDistance( cycleinfo1.getPositionPair().second(), cycleinfo3.getPositionPair().second()) < MoveConstants.TRAFFIC_CHECKING_DISTANCE) { Path randomPath = bfs.getDummyRandomWalkPath(); me.send( new AKMove( me.getID(), me.time(), randomPath.getIds(), randomPath.getDestination().second().getIntX(), randomPath.getDestination().second().getIntY())); sendStockMessage(path); me.informationStacker.addInfo(me.model(), new StockMoveAction(randomPath)); throw new SOSActionException("Move Stock Random Walk(" + randomPath + ")"); } }
@SuppressWarnings("unused") private void check4CycleStock() throws SOSActionException { CycleInformations cycleinfo1 = me.informationStacker.getInformations(1); CycleInformations cycleinfo2 = me.informationStacker.getInformations(2); CycleInformations cycleinfo3 = me.informationStacker.getInformations(3); CycleInformations cycleinfo4 = me.informationStacker.getInformations(4); if (cycleinfo2.getAct() instanceof StockMoveAction) return; if (cycleinfo1.getAct() instanceof MoveAction && cycleinfo2.getAct() instanceof MoveAction && cycleinfo3.getAct() instanceof MoveAction && cycleinfo4.getAct() instanceof MoveAction) { // Path path1 = ((MoveAction) cycleinfo1.getAct()).getPath(); // Path path2 = ((MoveAction) cycleinfo2.getAct()).getPath(); // Path path3 = ((MoveAction) cycleinfo3.getAct()).getPath(); // Path path4 = ((MoveAction) cycleinfo4.getAct()).getPath(); log().debug("Four(4) cycle move ...."); log().debug("1 cycle ago position:" + cycleinfo1.getPositionPair()); log().debug("2 cycle ago position:" + cycleinfo2.getPositionPair()); log().debug("3 cycle ago position:" + cycleinfo3.getPositionPair()); log().debug("4 cycle ago position:" + cycleinfo4.getPositionPair()); if (cycleinfo1.getPositionPair().first().equals(cycleinfo2.getPositionPair().first()) && cycleinfo1.getPositionPair().first().equals(cycleinfo3.getPositionPair().first()) && cycleinfo1.getPositionPair().first().equals(cycleinfo4.getPositionPair().first())) { if (SOSGeometryTools.getDistance( cycleinfo1.getPositionPair().second(), cycleinfo2.getPositionPair().second()) < MoveConstants.TRAFFIC_CHECKING_DISTANCE && SOSGeometryTools.getDistance( cycleinfo1.getPositionPair().second(), cycleinfo3.getPositionPair().second()) < MoveConstants.TRAFFIC_CHECKING_DISTANCE && SOSGeometryTools.getDistance( cycleinfo1.getPositionPair().second(), cycleinfo4.getPositionPair().second()) < MoveConstants.TRAFFIC_CHECKING_DISTANCE) { //////////////////// DO TRAFFIC///////////////////////////// log().warn("4 cycle stock!--> do random walk"); move(bfs.getDummyRandomWalkPath(), false); } } } }