/** * Princess's home edge. * * @param destinationEdge the index of the {@link CardinalEdge} princess should flee to. See {@link CardinalEdge#getIndex()} */ public void setDestinationEdge(final String destinationEdge) throws PrincessException { try { setDestinationEdge(Integer.parseInt(destinationEdge.trim())); } catch (final NumberFormatException e) { throw new PrincessException("Invalid destinationEdge value.", e); } }
/** * 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)); }
public void setDestinationEdge(int i) { behaviorSettings.setDestinationEdge(findCardinalEdge(i)); }
private void getPrincessFields() { LogLevel logLevel = LogLevel.getLogLevel((String) verbosityCombo.getSelectedItem()); if (null != logLevel) { princessBehavior.setVerbosity(logLevel); } princessBehavior.setForcedWithdrawal(forcedWithdrawalCheck.isSelected()); princessBehavior.setAutoFlee(autoFleeCheck.isSelected()); princessBehavior.setSelfPreservationIndex(selfPreservationSlidebar.getValue()); princessBehavior.setHyperAggressionIndex(aggressionSlidebar.getValue()); princessBehavior.setFallShameIndex(fallShameSlidebar.getValue()); princessBehavior.setDestinationEdge(destinationEdgeCombo.getSelectedIndex()); princessBehavior.setRetreatEdge(retreatEdgeCombo.getSelectedIndex()); princessBehavior.setHerdMentalityIndex(herdingSlidebar.getValue()); princessBehavior.setBraveryIndex(braverySlidebar.getValue()); }
setSelfPreservationIndex(child.getTextContent()); } else if ("destinationEdge".equalsIgnoreCase(child.getNodeName())) { setDestinationEdge(child.getTextContent()); } else if ("retreatEdge".equalsIgnoreCase(child.getNodeName())) { setRetreatEdge(child.getTextContent());
behaviorSettings.setHyperAggressionIndex(Integer.parseInt(wn3.getTextContent())); } else if (wn3.getNodeName().equalsIgnoreCase("destinationEdge")) { behaviorSettings.setDestinationEdge(Integer.parseInt(wn3.getTextContent())); } else if (wn3.getNodeName().equalsIgnoreCase("retreatEdge")) { behaviorSettings.setRetreatEdge(Integer.parseInt(wn3.getTextContent()));
public BotForce(String name, int team, int start, int home, ArrayList<Entity> entityList, String camoCategory, String camoFileName, int colorIndex) { final String METHOD_NAME = "BotForce(String,int,int,int,ArrayList<Entity>,String,String,int)"; //$NON-NLS-1$ this.name = name; this.team = team; this.start = start; this.entityList = entityList; this.camoCategory = camoCategory; this.camoFileName = camoFileName; this.colorIndex = colorIndex; try { behaviorSettings = BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR.getCopy(); } catch (PrincessException ex) { MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, "Error getting Princess default behaviors"); //$NON-NLS-1$ MekHQ.getLogger().error(getClass(), METHOD_NAME, ex); } behaviorSettings.setRetreatEdge(CardinalEdge.NEAREST_OR_NONE); behaviorSettings.setDestinationEdge(CardinalEdge.NEAREST_OR_NONE); }
tempBehavior.setForcedWithdrawal(forcedWithdrawalCheck.isSelected()); tempBehavior.setAutoFlee(autoFleeCheck.isSelected()); tempBehavior.setDestinationEdge(destinationEdgeCombo.getSelectedIndex()); tempBehavior.setRetreatEdge(retreatEdgeCombo.getSelectedIndex()); tempBehavior.setHyperAggressionIndex(aggressionSlidebar.getValue());
private BehaviorSettings buildCowardlyBehavior() { try { BehaviorSettings cowardlyBehavior = new BehaviorSettings(); cowardlyBehavior.setDescription(COWARDLY_BEHAVIOR_DESCRIPTION); cowardlyBehavior.setDestinationEdge(CardinalEdge.NEAREST_OR_NONE); cowardlyBehavior.setRetreatEdge(CardinalEdge.NEAREST_OR_NONE); cowardlyBehavior.setForcedWithdrawal(true); cowardlyBehavior.setAutoFlee(false); cowardlyBehavior.setFallShameIndex(8); cowardlyBehavior.setHyperAggressionIndex(1); cowardlyBehavior.setSelfPreservationIndex(10); cowardlyBehavior.setHerdMentalityIndex(8); cowardlyBehavior.setBraveryIndex(2); return cowardlyBehavior; } catch (Exception e) { getLogger().error(BehaviorSettingsFactory.class, "buildCowardlyBehavior", e); return null; } }
private BehaviorSettings buildEscapeBehavior() { try { BehaviorSettings escapeBehavior = new BehaviorSettings(); escapeBehavior.setDescription(ESCAPE_BEHAVIOR_DESCRIPTION); escapeBehavior.setDestinationEdge(CardinalEdge.NEAREST_OR_NONE); escapeBehavior.setRetreatEdge(CardinalEdge.NEAREST_OR_NONE); escapeBehavior.setForcedWithdrawal(true); escapeBehavior.setAutoFlee(true); escapeBehavior.setFallShameIndex(7); escapeBehavior.setHyperAggressionIndex(3); escapeBehavior.setSelfPreservationIndex(10); escapeBehavior.setHerdMentalityIndex(5); escapeBehavior.setBraveryIndex(2); return escapeBehavior; } catch (Exception e) { getLogger().error(BehaviorSettingsFactory.class, "buildEscapeBehavior", e); return null; } }
private BehaviorSettings buildBerserkBehavior() { try { BehaviorSettings berserkBehavior = new BehaviorSettings(); berserkBehavior.setDescription(BERSERK_BEHAVIOR_DESCRIPTION); berserkBehavior.setDestinationEdge(CardinalEdge.NEAREST_OR_NONE); berserkBehavior.setRetreatEdge(CardinalEdge.NEAREST_OR_NONE); berserkBehavior.setForcedWithdrawal(false); berserkBehavior.setAutoFlee(false); berserkBehavior.setFallShameIndex(2); berserkBehavior.setHyperAggressionIndex(10); berserkBehavior.setSelfPreservationIndex(2); berserkBehavior.setHerdMentalityIndex(5); berserkBehavior.setBraveryIndex(9); return berserkBehavior; } catch (Exception e) { getLogger().error(BehaviorSettingsFactory.class, "buildBerserkBehavior", e); return null; } }
private BehaviorSettings buildDefaultBehavior() { try { BehaviorSettings defaultBehavior = new BehaviorSettings(); defaultBehavior.setDescription(DEFAULT_BEHAVIOR_DESCRIPTION); defaultBehavior.setDestinationEdge(CardinalEdge.NEAREST_OR_NONE); defaultBehavior.setRetreatEdge(CardinalEdge.NEAREST_OR_NONE); defaultBehavior.setForcedWithdrawal(true); defaultBehavior.setAutoFlee(false); defaultBehavior.setFallShameIndex(5); defaultBehavior.setHyperAggressionIndex(5); defaultBehavior.setSelfPreservationIndex(5); defaultBehavior.setHerdMentalityIndex(5); defaultBehavior.setBraveryIndex(5); return defaultBehavior; } catch (Exception e) { getLogger().error(BehaviorSettingsFactory.class, "buildDefaultBehavior", e); return null; } } //******************
/** * 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); }
public BehaviorSettings getCopy() throws PrincessException { final BehaviorSettings copy = new BehaviorSettings(); copy.setDestinationEdge(getDestinationEdge()); copy.setRetreatEdge(getRetreatEdge()); copy.setForcedWithdrawal(isForcedWithdrawal()); copy.setAutoFlee(shouldAutoFlee()); copy.setDescription(getDescription()); copy.setFallShameIndex(getFallShameIndex()); copy.setBraveryIndex(getBraveryIndex()); copy.setHerdMentalityIndex(getHerdMentalityIndex()); copy.setHyperAggressionIndex(getHyperAggressionIndex()); copy.setSelfPreservationIndex(getSelfPreservationIndex()); copy.setVerbosity(getVerbosity()); for (final String t : getStrategicBuildingTargets()) { copy.addStrategicTarget(t); } for (final Integer p : getPriorityUnitTargets()) { copy.addPriorityUnit(p); } return copy; }