/** * Adds a {@link megamek.client.bot.princess.BehaviorSettings} to the cache. If a behavior with the same name is already in the cache, it will * be overwritten. * * @param behaviorSettings The {@link megamek.client.bot.princess.BehaviorSettings} to be added to the cache. */ public void addBehavior(BehaviorSettings behaviorSettings) { synchronized (behaviorMap) { behaviorMap.put(behaviorSettings.getDescription().trim(), behaviorSettings); } }
private void addDefaultBehaviors() { if (!behaviorMap.keySet().contains(DEFAULT_BEHAVIOR_DESCRIPTION)) { addBehavior(DEFAULT_BEHAVIOR); } if (!behaviorMap.keySet().contains(BERSERK_BEHAVIOR.getDescription())) { addBehavior(BERSERK_BEHAVIOR); } if (!behaviorMap.keySet().contains(COWARDLY_BEHAVIOR.getDescription())) { addBehavior(COWARDLY_BEHAVIOR); } if (!behaviorMap.keySet().contains(ESCAPE_BEHAVIOR.getDescription())) { addBehavior(ESCAPE_BEHAVIOR); } }
public BasicPathRanker(Princess owningPrincess) { super(owningPrincess); final String METHOD_NAME = "BasicPathRanker(Princess)"; bestDamageByEnemies = new TreeMap<>(); getOwner().log( getClass(), METHOD_NAME, LogLevel.DEBUG, "Using " + getOwner().getBehaviorSettings().getDescription() + " behavior"); }
/** * @return A string log of these behavior settings. */ public String toLog() { final StringBuilder out = new StringBuilder("Princess Behavior: ").append(getDescription()); out.append("\n\tDestination Edge: ").append(getDestinationEdge()); out.append("\n\tRetreat Edge: ").append(getRetreatEdge()); out.append("\n\tForced Withdrawal: ").append(isForcedWithdrawal()); out.append("\n\tSelf Preservation: ").append(getSelfPreservationIndex()); out.append("\n\tHyper Aggression: ").append(getHyperAggressionIndex()); out.append("\n\tFall Shame: ").append(getFallShameIndex()); out.append("\n\tBravery: ").append(getBraveryIndex()); out.append("\n\tHerd Mentality: ").append(getHerdMentalityIndex()); out.append("\n\tVerbosity: ").append(getVerbosity()); out.append("\n\tTargets:"); out.append("\n\t\tCoords: "); for (final String t : getStrategicBuildingTargets()) { out.append(" ").append(t); } out.append("\n\t\tUnits:"); for (final int id : getPriorityUnitTargets()) { out.append(" ").append(id); } return out.toString(); }
nameNode.setTextContent(StringUtil.makeXmlSafe(getDescription())); behavior.appendChild(nameNode);
result.append(" has replaced ").append(target.getName()).append("."); if (botClient instanceof Princess) { result.append(" Config: ").append(((Princess) botClient).getBehaviorSettings().getDescription()).append ("."); result.append(" Verbosity: ").append(((Princess) botClient).getVerbosity()).append(".");
"/replacePlayer", "-b:Princess", "-c:" + ((Princess) botClient).getBehaviorSettings().getDescription(), "-v:" + ((Princess) botClient).getVerbosity(), "-p:" + player
msg = "Current Behavior: " + princess.getBehaviorSettings().getDescription(); princess.sendChat(msg); princess.log(getClass(), METHOD_NAME, LogLevel.INFO, msg); msg = "Behavior changed to " + princess.getBehaviorSettings().getDescription(); princess.sendChat(msg); return;
behaviorSettings.setLogger(new FakeLogger()); behaviorSettings.fromXml(testBehaviorElement); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_BEHAVIOR_NAME, behaviorSettings.getDescription()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_HOME_EDGE, behaviorSettings.getRetreatEdge()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_DESTINATION_EDGE, behaviorSettings.getDestinationEdge()); behaviorSettings.setLogger(new FakeLogger()); behaviorSettings.fromXml(testBehaviorElement); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_BEHAVIOR_NAME, behaviorSettings.getDescription()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_HOME_EDGE, behaviorSettings.getRetreatEdge()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_DESTINATION_EDGE, behaviorSettings.getDestinationEdge()); behaviorSettings.setLogger(new FakeLogger()); behaviorSettings.fromXml(testBehaviorElement); Assert.assertEquals("null", behaviorSettings.getDescription()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_HOME_EDGE, behaviorSettings.getRetreatEdge()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_DESTINATION_EDGE, behaviorSettings.getDestinationEdge()); behaviorSettings.setLogger(new FakeLogger()); behaviorSettings.fromXml(testBehaviorElement); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_BEHAVIOR_NAME, behaviorSettings.getDescription()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_HOME_EDGE, behaviorSettings.getRetreatEdge()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_DESTINATION_EDGE, behaviorSettings.getDestinationEdge()); behaviorSettings.setLogger(new FakeLogger()); behaviorSettings.fromXml(testBehaviorElement); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_BEHAVIOR_NAME, behaviorSettings.getDescription()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_HOME_EDGE, behaviorSettings.getRetreatEdge()); Assert.assertEquals(BehaviorSettingsTestConstants.GOOD_DESTINATION_EDGE, behaviorSettings.getDestinationEdge());
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; }