/** * 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)); }
@Override public int hashCode() { int result = description.hashCode(); result = 31 * result + (forcedWithdrawal ? 1 : 0); result = 31 * result + (goHome ? 1 : 0); result = 31 * result + (autoFlee ? 1 : 0); result = 31 * result + selfPreservationIndex; result = 31 * result + fallShameIndex; result = 31 * result + hyperAggressionIndex; result = 31 * result + destinationEdge.hashCode(); result = 31 * result + retreatEdge.hashCode(); result = 31 * result + (null != strategicBuildingTargets ? strategicBuildingTargets.hashCode() : 0); result = 31 * result + (null != priorityUnitTargets ? priorityUnitTargets.hashCode() : 0); result = 31 * result + herdMentalityIndex; result = 31 * result + braveryIndex; return result; } }
/** * 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); }
protected void setPrincessFields() { verbosityCombo.setSelectedIndex(0); forcedWithdrawalCheck.setSelected(princessBehavior.isForcedWithdrawal()); autoFleeCheck.setSelected(princessBehavior.shouldAutoFlee()); selfPreservationSlidebar.setValue(princessBehavior.getSelfPreservationIndex()); aggressionSlidebar.setValue(princessBehavior.getHyperAggressionIndex()); fallShameSlidebar.setValue(princessBehavior.getFallShameIndex()); destinationEdgeCombo.setSelectedIndex(princessBehavior.getDestinationEdge().getIndex()); retreatEdgeCombo.setSelectedIndex(princessBehavior.getRetreatEdge().getIndex()); herdingSlidebar.setValue(princessBehavior.getHerdMentalityIndex()); braverySlidebar.setValue(princessBehavior.getBraveryIndex()); targetsListModel.clear(); for (String t : princessBehavior.getStrategicBuildingTargets()) { //noinspection unchecked targetsListModel.addElement(BUILDING_TARGET + ": " + t); } for (int id : princessBehavior.getPriorityUnitTargets()) { targetsListModel.addElement(UNIT_TARGET + ": " + id); } repaint(); }
cboDestinationZone.setSelectedIndex(CardinalEdge.NEAREST_OR_NONE.ordinal()); gbc.gridx = 1; forcedPanel.add(cboDestinationZone, gbc);
int boardWidth = game.getBoard().getWidth(); StringBuilder msg = new StringBuilder("Getting distance to home edge: "); if (CardinalEdge.NORTH.equals(homeEdge)) { msg.append("North"); edgeCoords = new Coords(position.getX(), 0); } else if (CardinalEdge.SOUTH.equals(homeEdge)) { msg.append("South"); edgeCoords = new Coords(position.getX(), boardHeight); } else if (CardinalEdge.WEST.equals(homeEdge)) { msg.append("West"); edgeCoords = new Coords(0, position.getY()); } else if (CardinalEdge.EAST.equals(homeEdge)) { msg.append("East"); edgeCoords = new Coords(boardWidth, position.getY());
String msg = "Getting distance to home edge: " + homeEdge.toString();
public void writeToXml(PrintWriter pw1, int indent) { MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "name", MekHqXmlUtil.escape(name)); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "team", team); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "start", start); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "camoCategory", MekHqXmlUtil.escape(camoCategory)); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "camoFileName", MekHqXmlUtil.escape(camoFileName)); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+1, "colorIndex", colorIndex); pw1.println(MekHqXmlUtil.indentStr(indent+1) + "<entities>"); for (Entity en : entityList) { if (en != null) { pw1.println(AtBScenario.writeEntityWithCrewToXmlString(en, indent + 2, entityList)); } } pw1.println(MekHqXmlUtil.indentStr(indent+1) + "</entities>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) + "<behaviorSettings>"); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "verbosity", behaviorSettings.getVerbosity().toString()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "forcedWithdrawal", behaviorSettings.isForcedWithdrawal()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "autoFlee", behaviorSettings.shouldAutoFlee()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "selfPreservationIndex", behaviorSettings.getSelfPreservationIndex()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "fallShameIndex", behaviorSettings.getFallShameIndex()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "hyperAggressionIndex", behaviorSettings.getHyperAggressionIndex()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "destinationEdge", behaviorSettings.getDestinationEdge().ordinal()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "retreatEdge", behaviorSettings.getRetreatEdge().ordinal()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "herdMentalityIndex", behaviorSettings.getHerdMentalityIndex()); MekHqXmlUtil.writeSimpleXmlTag(pw1, indent+2, "braveryIndex", behaviorSettings.getBraveryIndex()); pw1.println(MekHqXmlUtil.indentStr(indent+1) + "</behaviorSettings>"); }
/** * 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)); }
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; }