private double calculateFallMod(double successProbability, StringBuilder formula) { double pilotingFailure = (1 - successProbability); double fallShame = getOwner().getBehaviorSettings().getFallShameValue(); double fallMod = pilotingFailure * (pilotingFailure == 1 ? -1000 : fallShame); formula.append("fall mod [").append(LOG_DECIMAL.format(fallMod)).append(" = ") .append(LOG_DECIMAL.format(pilotingFailure)).append(" * ").append(LOG_DECIMAL.format(fallShame)) .append("]"); return fallMod; }
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"); }
protected double calculateHerdingMod(Coords friendsCoords, MovePath path, StringBuilder formula) { if (friendsCoords == null) { formula.append(" - herdingMod [0 no friends]"); return 0; } double distanceToAllies = friendsCoords.distance(path.getFinalCoords()); double herding = getOwner().getBehaviorSettings() .getHerdMentalityValue(); double herdingMod = distanceToAllies * herding; formula.append(" - herdingMod [").append(LOG_DECIMAL.format(herdingMod)) .append(" = ") .append(LOG_DECIMAL.format(distanceToAllies)).append(" * ") .append(LOG_DECIMAL.format(herding)) .append("]"); return herdingMod; }
protected double calculateAggressionMod(Entity movingUnit, MovePath path, IGame game, StringBuilder formula) { double distToEnemy = distanceToClosestEnemy(movingUnit, path.getFinalCoords(), game); if ((distToEnemy == 0) && !(movingUnit instanceof Infantry)) { distToEnemy = 2; } double aggression = getOwner().getBehaviorSettings() .getHyperAggressionValue(); double aggressionMod = distToEnemy * aggression; formula.append(" - aggressionMod [") .append(LOG_DECIMAL.format(aggressionMod)).append(" = ") .append(LOG_DECIMAL.format(distToEnemy)).append(" * ") .append(LOG_DECIMAL.format(aggression)).append("]"); return aggressionMod; }
protected double calculateSelfPreservationMod(Entity movingUnit, MovePath path, IGame game, StringBuilder formula) { if (getOwner().getFallBack() || movingUnit.isCrippled()) { int newDistanceToHome = distanceToHomeEdge(path.getFinalCoords(), getOwner().getHomeEdge(movingUnit), game); double selfPreservation = getOwner().getBehaviorSettings() .getSelfPreservationValue(); double selfPreservationMod = newDistanceToHome * selfPreservation; formula.append(" - selfPreservationMod [") .append(LOG_DECIMAL.format(selfPreservationMod)) .append(" = ").append(LOG_DECIMAL.format(newDistanceToHome)) .append(" * ") .append(LOG_DECIMAL.format(selfPreservation)).append("]"); return selfPreservationMod; } return 0.0; }
/** * Gives the distance to the closest enemy unit, or zero if none exist * * @param me Entity who has enemies * @param position Coords from which the closest enemy is found * @param game IGame that we're playing */ public double distanceToClosestEnemy(Entity me, Coords position, IGame game) { final String METHOD_NAME = "distanceToClosestEnemy(Entity, Coords, IGame)"; getOwner().methodBegin(BasicPathRanker.class, METHOD_NAME); try { Entity closest = findClosestEnemy(me, position, game); if (closest == null) { return 0; } return closest.getPosition().distance(position); } finally { getOwner().methodEnd(BasicPathRanker.class, METHOD_NAME); } }
public void initUnitTurn(Entity unit, IGame game) { final String METHOD_NAME = "initUnitTurn(Entity, IGame)"; getOwner().methodBegin(getClass(), METHOD_NAME); List<Entity> enemies = getOwner().getEnemyEntities(); List<Entity> friends = getOwner().getFriendEntities(); for (Entity e : enemies) { double max_damage = 0; getOwner().methodEnd(getClass(), METHOD_NAME);
boolean canFlankAndKick(Entity enemy, Coords behind, Coords leftFlank, Coords rightFlank, int myFacing) { final String METHOD_NAME = "canFlankAndKick(Entity, Coords, Coords, " + "Coords, int)"; Set<CoordFacingCombo> enemyFacingSet = pathEnumerator.getUnitPotentialLocations().get(enemy.getId()); if (enemyFacingSet == null) { getOwner().log(getClass(), METHOD_NAME, LogLevel.WARNING, "no facing set for " + enemy.getDisplayName()); return false; } return enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, (myFacing + 1) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(behind, (myFacing + 5) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, (myFacing + 4) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(leftFlank, (myFacing + 5) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, myFacing)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, (myFacing + 1) % 6)) || enemyFacingSet.contains(CoordFacingCombo.createCoordFacingCombo(rightFlank, (myFacing + 2) % 6)); }
public int distanceToHomeEdge(Coords position, CardinalEdge homeEdge, IGame game) { final String METHOD_NAME = "distanceToHomeEdge(Coords, HomeEdge, IGame)"; getOwner().methodBegin(BasicPathRanker.class, METHOD_NAME); getOwner().log(getClass(), METHOD_NAME, LogLevel.WARNING, "Invalid home edge. Defaulting to NORTH."); distance = position.getY(); getOwner().log(BasicPathRanker.class, METHOD_NAME, msg); return distance; } finally { getOwner().methodEnd(BasicPathRanker.class, METHOD_NAME);
double calculateKickDamagePotential(Entity enemy, MovePath path, IGame game) { if (!(enemy instanceof Mech)) { return 0.0; } // if they can kick me, and probably hit, they probably will. PhysicalInfo theirKick = new PhysicalInfo(enemy, null, path.getEntity(), new EntityState(path), PhysicalAttackType.RIGHT_KICK, game, getOwner(), true); if (theirKick.getProbabilityToHit() <= 0.5) { return 0.0; } return theirKick.getExpectedDamageOnHit() * theirKick.getProbabilityToHit(); }
"EntityEvaluationResponse evaluateUnmovedEnemy(Entity," + "MovePath,IGame)"; getOwner().methodBegin(getClass(), METHOD_NAME); if (path.getEntity().canChangeSecondaryFacing()) { leftBounds = new HexLine(behind, (myFacing + 2) % 6, getOwner()); rightBounds = new HexLine(behind, (myFacing + 4) % 6, getOwner()); } else { leftBounds = new HexLine(behind, (myFacing + 1) % 6, getOwner()); rightBounds = new HexLine(behind, (myFacing + 5) % 6, getOwner()); getOwner().methodEnd(getClass(), METHOD_NAME);
double calculateMyKickDamagePotential(MovePath path, Entity enemy, IGame game) { if (!(path.getEntity() instanceof Mech)) { return 0.0; } PhysicalInfo myKick = new PhysicalInfo(path.getEntity(), new EntityState(path), enemy, null, PhysicalAttackType.RIGHT_KICK, game, getOwner(), true); if (myKick.getProbabilityToHit() <= 0.5) { return 0; } return myKick.getExpectedDamageOnHit() * myKick.getProbabilityToHit(); }
"double, int, int, List<Entity>, Coords)"; getOwner().methodBegin(getClass(), METHOD_NAME); if (getOwner().getHonorUtil().isEnemyBroken(enemy.getId(), enemy.getOwnerId(), getOwner().getForcedWithdrawal())) { continue; Map<Coords, Double> artyDamage = getOwner().getPathRankerState().getIncomingFriendlyArtilleryDamage(); friendlyArtilleryDamage = ArtilleryTargetingControl.evaluateIncomingArtilleryDamage(path.getFinalCoords(), getOwner()); artyDamage.put(path.getFinalCoords(), friendlyArtilleryDamage); } else { calcDamageToStrategicTargets(pathCopy, game, getOwner().getFireControlState(), damageEstimate); getOwner().getBehaviorSettings().getBraveryValue(); double braveryMod = successProbability * ((maximumDamageDone * return rankedPath; } finally { getOwner().methodEnd(getClass(), METHOD_NAME);
/** * Gives the distance to the closest edge */ int distanceToClosestEdge(Coords position, IGame game) { final String METHOD_NAME = "distanceToClosestEdge(Coords, IGame)"; getOwner().methodBegin(BasicPathRanker.class, METHOD_NAME); try { int width = game.getBoard().getWidth(); int height = game.getBoard().getHeight(); int minimum = position.getX(); if ((width - position.getX()) < minimum) { minimum = position.getX(); } if (position.getY() < minimum) { minimum = position.getY(); } if ((height - position.getY()) < minimum) { minimum = height - position.getY(); } return minimum; } finally { getOwner().methodEnd(BasicPathRanker.class, METHOD_NAME); } }
@Test public void testEvaluateMovedEnemy() { final BasicPathRanker testRanker = Mockito.spy(new BasicPathRanker(mockPrincess)); Mockito.doReturn(mockPrincess).when(testRanker).getOwner();
@Test public void testEvaluateUnmovedEnemy() { final BasicPathRanker testRanker = Mockito.spy(new BasicPathRanker(mockPrincess)); Mockito.doReturn(mockPrincess).when(testRanker).getOwner();
getOwner().log(getClass(), METHOD_NAME, LogLevel.DEBUG, logMsg);
path.getEntity(), new EntityState(path), target, null, PhysicalAttackType.RIGHT_KICK, game, getOwner(), true); double expectedKickDamage =