/** * Princess's home edge. * * @param retreatEdge the index of the {@link CardinalEdge} princess should flee to. See {@link CardinalEdge#getIndex()} */ public void setRetreatEdge(final int retreatEdge) { setRetreatEdge(CardinalEdge.getCardinalEdge(retreatEdge)); }
/** * Princess's home edge. * * @param destinationEdge the index of the {@link CardinalEdge} princess should flee to. See {@link CardinalEdge#getIndex()} */ public void setDestinationEdge(final int destinationEdge) { setDestinationEdge(CardinalEdge.getCardinalEdge(destinationEdge)); }
setPrincessFields(); } else if (destinationEdgeCombo.equals(e.getSource())) { if (CardinalEdge.getCardinalEdge(destinationEdgeCombo.getSelectedIndex()) == CardinalEdge.NEAREST_OR_NONE) { autoFleeCheck.setSelected(false); autoFleeCheck.setEnabled(false);
public CardinalEdge findCardinalEdge(int start) { switch (start) { case Board.START_N: return CardinalEdge.NORTH; case Board.START_S: return CardinalEdge.SOUTH; case Board.START_E: return CardinalEdge.EAST; case Board.START_W: return CardinalEdge.WEST; case Board.START_NW: return (Compute.randomInt(2) == 0) ? CardinalEdge.NORTH : CardinalEdge.WEST; case Board.START_NE: return (Compute.randomInt(2) == 0) ? CardinalEdge.NORTH : CardinalEdge.EAST; case Board.START_SW: return (Compute.randomInt(2) == 0) ? CardinalEdge.SOUTH : CardinalEdge.WEST; case Board.START_SE: return (Compute.randomInt(2) == 0) ? CardinalEdge.SOUTH : CardinalEdge.EAST; case Board.START_ANY: return CardinalEdge.getCardinalEdge(Compute.randomInt(4)); default: return CardinalEdge.NEAREST_OR_NONE; } }
/** * Tells me whether this path will result in me flying to a location * from which there is absolutely no way to remain on the board the following turn. * * We also take into account the possibility that we are intentionally trying to * a) retreat * b) fly off a particular edge * @param path The path to examine * @return 0 if we are A-Ok with it, .5 (maybe tune this) if we aren't looking to go off board */ @Override protected double calculateOffBoardMod(MovePath path) { // step one: project given path's vector over the next turn. OffBoardDirection offBoardDirection = calculateOffBoardDirection(path.getEntity(), path.getFinalCoords(), path.getFinalVectors()); // if we want to flee the board from the edge in question, we're ok if(getOwner().isFallingBack(path.getEntity()) && (getOwner().getHomeEdge(path.getEntity()) == CardinalEdge.getCardinalEdge(offBoardDirection.getValue()))) { return 0.0; } if(offBoardDirection == OffBoardDirection.NONE) { return 0.0; } return .5; }
/** * Determines and sets the destination edge for a given bot force that follows a given force template. * @param force The bot force for which to set the edge. * @param forceTemplate The template which governs the destination edge. */ private static void setDestinationZone(BotForce force, ScenarioForceTemplate forceTemplate) { int actualDestinationEdge = forceTemplate.getDestinationZone(); // set the 'auto flee' flag to true if the bot has a destination edge if(actualDestinationEdge != CardinalEdge.NEAREST_OR_NONE.ordinal()) { force.getBehaviorSettings().setAutoFlee(true); } if(forceTemplate.getDestinationZone() == ScenarioForceTemplate.DESTINATION_EDGE_RANDOM) { // compute a random cardinal edge between 0 and 3 to avoid None actualDestinationEdge = Compute.randomInt(CardinalEdge.values().length - 1); } else if (forceTemplate.getDestinationZone() == ScenarioForceTemplate.DESTINATION_EDGE_OPPOSITE_DEPLOYMENT) { actualDestinationEdge = getOppositeEdge(force.getStart()); } else { force.getBehaviorSettings().setDestinationEdge(CardinalEdge.getCardinalEdge(actualDestinationEdge)); return; } force.setDestinationEdge(actualDestinationEdge); }