public BotForce() { this.entityList = new ArrayList<Entity>(); try { behaviorSettings = BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR.getCopy(); } catch (PrincessException ex) { MekHQ.getLogger().log(getClass(), "BotForce()", LogLevel.ERROR, //$NON-NLS-1$ "Error getting Princess default behaviors"); //$NON-NLS-1$ MekHQ.getLogger().error(getClass(), "BotForce()", ex); //$NON-NLS-1$ } };
botClient = makeNewPrincessClient(target, verbosity, host, port); if (!StringUtil.isNullOrEmpty(configName)) { final BehaviorSettings behavior = BehaviorSettingsFactory.getInstance() .getBehavior(configName.toString()); if (null != behavior) { } else { results.add("Unrecognized Behavior Setting: '" + configName + "'. Using DEFAULT."); ((Princess) botClient).setBehaviorSettings(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR); ((Princess) botClient).setBehaviorSettings(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR);
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); }
/** * Constructor - initializes a new instance of the Princess bot. * @param name The display name. * @param host The host address to which to connect. * @param port The port on the host where to connect. * @param verbosity The verbosity of the bot's reporting and logging. */ public Princess(final String name, final String host, final int port, final LogLevel verbosity) { super(name, host, port); getLogger().setLogLevel(LOGGING_CATEGORY, verbosity); setBehaviorSettings(BehaviorSettingsFactory.getInstance(getLogger()) .DEFAULT_BEHAVIOR); fireControlState = new FireControlState(); pathRankerState = new PathRankerState(); // Start-up precog now, so that it can instantiate its game instance, // and it will stay up-to date. precognition = new Precognition(this); precogThread = new Thread(precognition, "Princess-precognition (" + getName() + ")"); precogThread.start(); }
BehaviorSettings newBehavior = BehaviorSettingsFactory.getInstance().getBehavior(behaviorName); if (newBehavior == null) { msg = "Behavior '" + behaviorName + "' does not exist.";
if (null != allyEntitiesForce) { allyEntitiesForce .setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy()); botForce.setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy());
mockPrincess = Mockito.spy(new Princess(mockBotPlayerVGer.getName(), "test", 1, LOG_LEVEL)); Mockito.doReturn(MOCK_GAME).when(mockPrincess).getGame(); mockPrincess.setBehaviorSettings(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Assert.assertEquals(BehaviorSettingsFactory.getInstance().COWARDLY_BEHAVIOR, mockPrincess.getBehaviorSettings()); mockPrincess = Mockito.spy(new Princess(mockBotPlayerVGer.getName(), "test", 1, LOG_LEVEL)); Mockito.doReturn(MOCK_GAME).when(mockPrincess).getGame(); mockPrincess.setBehaviorSettings(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString()); testChatProcessor.additionalPrincessCommands(mockChatEvent, mockPrincess); Assert.assertEquals(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR, mockPrincess.getBehaviorSettings()); mockPrincess = Mockito.spy(new Princess(mockBotPlayerVGer.getName(), "test", 1, LOG_LEVEL)); Mockito.doReturn(MOCK_GAME).when(mockPrincess).getGame(); mockPrincess.setBehaviorSettings(BehaviorSettingsFactory.getInstance().DEFAULT_BEHAVIOR); Mockito.doNothing().when(mockPrincess).log(Matchers.any(Class.class), Matchers.anyString(), Matchers.any(LogLevel.class), Matchers.anyString()); Mockito.doNothing().when(mockPrincess).sendChat(Matchers.anyString());
if (isAttacker()) { BotForce bf = new BotForce("Civilians", 1, otherStart, playerHome, otherForce); bf.setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy()); bf.setDestinationEdge(otherHome); bf.setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy()); bf.setDestinationEdge(otherHome);
if (null != allyEntitiesForce) { allyEntitiesForce .setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy()); botForce.setBehaviorSettings(BehaviorSettingsFactory.getInstance().ESCAPE_BEHAVIOR.getCopy()); botForce.setDestinationEdge(destinationEdge);
actual = testAddBotUtil.addBot(args, mockGame, mockClient.getHost(), mockClient.getPort()); TestCase.assertEquals(expected, actual); BehaviorSettings expectedBehavior = BehaviorSettingsFactory.getInstance().getBehavior("BERSERK"); TestCase.assertEquals(expectedBehavior, mockPrincess.getBehaviorSettings()); actual = testAddBotUtil.addBot(args, mockGame, mockClient.getHost(), mockClient.getPort()); TestCase.assertEquals(expected, actual); expectedBehavior = BehaviorSettingsFactory.getInstance().getBehavior("ESCAPE"); TestCase.assertEquals(expectedBehavior, mockPrincess.getBehaviorSettings()); actual = testAddBotUtil.addBot(args, mockGame, mockClient.getHost(), mockClient.getPort()); TestCase.assertEquals(expected, actual); expectedBehavior = BehaviorSettingsFactory.getInstance().getBehavior("DEFAULT"); TestCase.assertEquals(expectedBehavior, mockPrincess.getBehaviorSettings()); actual = testAddBotUtil.addBot(args, mockGame, mockClient.getHost(), mockClient.getPort()); TestCase.assertEquals(expected, actual); expectedBehavior = BehaviorSettingsFactory.getInstance().getBehavior("ESCAPE"); TestCase.assertEquals(expectedBehavior, mockPrincess.getBehaviorSettings()); actual = testAddBotUtil.addBot(args, mockGame, mockClient.getHost(), mockClient.getPort()); TestCase.assertEquals(expected, actual); expectedBehavior = BehaviorSettingsFactory.getInstance().getBehavior("DEFAULT"); TestCase.assertEquals(expectedBehavior, mockPrincess.getBehaviorSettings());
addCivilianUnits(otherForce, 8, campaign); BotForce civilianForce = new BotForce("Base Civilian Units", isAttacker() ? 2 : 1, defenderStart, defenderHome, otherForce); civilianForce.setBehaviorSettings(BehaviorSettingsFactory.getInstance().COWARDLY_BEHAVIOR); addBotForce(civilianForce);