/** * calculates the 'utility' of a physical action. * * @param physicalInfo The {@link PhysicalInfo} to be calculated. */ void calculateUtility(final PhysicalInfo physicalInfo) { // If we can't hit, there's no point. if (0.0 >= physicalInfo.getProbabilityToHit()) { physicalInfo.setUtility(-10000); return; } double utility = DAMAGE_UTILITY * physicalInfo.getExpectedDamage(); utility += CRITICAL_UTILITY * physicalInfo.getExpectedCriticals(); utility += KILL_UTILITY * physicalInfo.getKillProbability(); utility *= calcTargetPotentialDamageMultiplier(physicalInfo.getTarget()); utility -= (physicalInfo.getTarget() instanceof MechWarrior) ? EJECTED_PILOT_DISUTILITY : 0; utility += calcCommandUtility(physicalInfo.getTarget()); utility += calcStrategicBuildingTargetUtility(physicalInfo.getTarget()); utility += calcPriorityUnitTargetUtility(physicalInfo.getTarget()); utility -= calcCivilianTargetDisutility(physicalInfo.getTarget()); physicalInfo.setUtility(utility); }
/** * Current bot code requires physical attacks to be given as 'physical option'. This does the necessary conversion */ public PhysicalOption getAsPhysicalOption() { int optionInteger = 0; if (getAttackType() == PhysicalAttackType.RIGHT_PUNCH) { optionInteger = PhysicalOption.PUNCH_RIGHT; } if (getAttackType() == PhysicalAttackType.LEFT_PUNCH) { optionInteger = PhysicalOption.PUNCH_LEFT; } if (getAttackType() == PhysicalAttackType.RIGHT_KICK) { optionInteger = PhysicalOption.KICK_RIGHT; } if (getAttackType() == PhysicalAttackType.LEFT_KICK) { optionInteger = PhysicalOption.KICK_LEFT; } return new PhysicalOption(getShooter(), getTarget(), 0, optionInteger, null); }
new StringBuilder("Initializing Damage for ").append(getShooter().getDisplayName()) .append(" ").append(physicalAttackType.toString()) .append(" at ").append(getTarget().getDisplayName()) .append(":"); targetState = new EntityState(getTarget()); setHitData(owner.getFireControl(getShooter()).guessToHitModifierPhysical(getShooter(), shooterState, getTarget(), targetState, getAttackType(), game)); } else { PhysicalAttackAction action = buildAction(physicalAttackType, getShooter().getId(), getTarget()); setAction(action); setHitData(physicalAttackType.isPunch() ? setKillProbability(0); if (!(getTarget() instanceof Mech)) { return; Mech targetMech = (Mech) getTarget(); for (int i = 0; i <= 7; i++) { int hitLoc = i;
Mockito.doReturn(0.02005).when(testPhysicalInfo).getKillProbability(); Mockito.doReturn(0.5).when(testPhysicalInfo).getProbabilityToHit(); Mockito.doReturn(mockPilot).when(testPhysicalInfo).getTarget(); testFireControl.calculateUtility(testPhysicalInfo); Assert.assertEquals(-979.3846, testPhysicalInfo.getUtility(), TOLERANCE);