/** * Variation on getTargetableEnemyEntities. * Returns all possible enemy targets, regardless of LOS status. * @param player The player from whose perspective enemies are determined. * @param game The game being played. * @return A list of potential targets. */ static List<Targetable> getAllTargetableEnemyEntities(final IPlayer player, final IGame game, final FireControlState fireControlState) { final List<Targetable> targetableEnemyList = new ArrayList<>(); // Go through every unit in the game. for (final Entity entity : game.getEntitiesVector()) { // If they are my enemy and on the board, they're a target. if (entity.getOwner().isEnemyOf(player) && (null != entity.getPosition()) && !entity.isOffBoard() && entity.isTargetable() && (null != entity.getCrew()) && !entity.getCrew().isDead()) { targetableEnemyList.add(entity); } } // Add in potential building targets and the like. targetableEnemyList.addAll(fireControlState.getAdditionalTargets()); return targetableEnemyList; }
/** * 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(); }
fireControlState.setAdditionalTargets(new ArrayList<>()); for (final Coords strategicTarget : getStrategicBuildingTargets()) { if (null == game.getBoard().getBuildingAt(strategicTarget)) { ", ignoring.", LogLevel.INFO); } else { fireControlState.getAdditionalTargets().add( new BuildingTarget(strategicTarget, game.getBoard(), false); if (isEnemyGunEmplacement(entity, coords)) { fireControlState.getAdditionalTargets().add(bt); sendChat("Building in Hex " + coords.toFriendlyString()
@Before public void setUp() { final BehaviorSettings mockBehavior = Mockito.mock(BehaviorSettings.class); Mockito.when(mockBehavior.getFallShameValue()).thenReturn(BehaviorSettings.FALL_SHAME_VALUES[5]); Mockito.when(mockBehavior.getBraveryValue()).thenReturn(BehaviorSettings.BRAVERY[5]); Mockito.when(mockBehavior.getHyperAggressionValue()).thenReturn(BehaviorSettings.HYPER_AGGRESSION_VALUES[5]); Mockito.when(mockBehavior.getHerdMentalityValue()).thenReturn(BehaviorSettings.HERD_MENTALITY_VALUES[5]); Mockito.when(mockBehavior.getSelfPreservationValue()).thenReturn(BehaviorSettings.SELF_PRESERVATION_VALUES[5]); mockFireControl = Mockito.mock(FireControl.class); final IHonorUtil mockHonorUtil = Mockito.mock(IHonorUtil.class); Mockito.when(mockHonorUtil.isEnemyBroken(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyBoolean())) .thenReturn(false); final List<Targetable> testAdditionalTargets = new ArrayList<>(); mockFireControlState = Mockito.mock(FireControlState.class); Mockito.when(mockFireControlState.getAdditionalTargets()).thenReturn(testAdditionalTargets); final Map<MovePath.Key, Double> testSuccessProbabilities = new HashMap<>(); mockPathRankerState = Mockito.mock(PathRankerState.class); Mockito.when(mockPathRankerState.getPathSuccessProbabilities()).thenReturn(testSuccessProbabilities); mockPrincess = Mockito.mock(Princess.class); Mockito.when(mockPrincess.getBehaviorSettings()).thenReturn(mockBehavior); Mockito.when(mockPrincess.getFireControl(FireControlType.Basic)).thenReturn(mockFireControl); Mockito.when(mockPrincess.getHomeEdge(Mockito.any(Entity.class))).thenReturn(CardinalEdge.NORTH); Mockito.when(mockPrincess.getHonorUtil()).thenReturn(mockHonorUtil); Mockito.when(mockPrincess.getLogger()).thenReturn(fakeLogger); Mockito.when(mockPrincess.getFireControlState()).thenReturn(mockFireControlState); Mockito.when(mockPrincess.getPathRankerState()).thenReturn(mockPathRankerState); }
fireControlState = new FireControlState(); pathRankerState = new PathRankerState();
/** * Gets all the entities that are potential targets * * @param shooter The unit doing the shooting. * @param game The game being played. * @return A list of potential targets. */ private List<Targetable> getTargetableEnemyEntities(final Entity shooter, final IGame game, final FireControlState fireControlState) { final List<Targetable> targetableEnemyList = new ArrayList<>(); // Go through every unit in the game. for (final Entity entity : game.getEntitiesVector()) { // If they are my enenmy and on the board, they're a target. if (entity.getOwner().isEnemyOf(shooter.getOwner()) && (null != entity.getPosition()) && !entity.isOffBoard() && entity.isTargetable() && (null != entity.getCrew()) && !entity.getCrew().isDead()) { final LosEffects effects = LosEffects.calculateLos(game, shooter.getId(), entity); if (effects.canSee()) { targetableEnemyList.add(entity); } } } // Add in potential building targets and the like. targetableEnemyList.addAll(fireControlState.getAdditionalTargets()); return targetableEnemyList; }
&& Compute.isInBuilding(game, entity) && !entity.isHidden()) { fireControlState.getAdditionalTargets().add(bt); sendChat("Building in Hex " + coords.toFriendlyString()
protected void calcDamageToStrategicTargets(MovePath path, IGame game, FireControlState fireControlState, FiringPhysicalDamage damageStructure) { for (int i = 0; i < fireControlState.getAdditionalTargets().size(); i++) { Targetable target = fireControlState.getAdditionalTargets().get(i);