String getDebugDescription(boolean detailed) { if (size() == 0) { return "Empty FiringPlan!"; } StringBuilder description = new StringBuilder("Firing Plan for ").append(get(0).getShooter().getChassis()) .append(" at ") .append(getTarget().getDisplayName()) .append("; ").append(Integer.toString(size())) .append(" weapons fired "); if (detailed) { for (WeaponFireInfo weaponFireInfo : this) { description.append("\n\t\t").append(weaponFireInfo.getDebugDescription()); } } DecimalFormat decimalFormat = new DecimalFormat("0.00000"); description.append("\n\tTotal Expected Damage=").append(decimalFormat.format(getExpectedDamage())); description.append("\n\tTotal Expected Criticals=").append(decimalFormat.format(getExpectedCriticals())); description.append("\n\tKill Probability=").append(decimalFormat.format(getKillProbability())); description.append("\n\tUtility=").append(decimalFormat.format(getUtility())); return description.toString(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof FiringPlan)) return false; if (!super.equals(o)) return false; FiringPlan that = (FiringPlan) o; final double TOLERANCE = 0.00001; if (twist != that.twist) return false; if (Math.abs(utility - that.utility) > TOLERANCE) return false; if (!target.equals(that.target)) return false; if (getHeat() != that.getHeat()) return false; if (Math.abs(getKillProbability() - that.getKillProbability()) > TOLERANCE) return false; if (Math.abs(getExpectedCriticals() - that.getExpectedCriticals()) > TOLERANCE) return false; //noinspection RedundantIfStatement if (Math.abs(getExpectedDamage() - that.getExpectedDamage()) > TOLERANCE) return false; return true; }
@Test public void testGetExpectedDamage() { Mockito.when(mockWeaponFireInfoMG.getExpectedDamageOnHit()).thenReturn(2.0); Mockito.when(mockWeaponFireInfoMG.getProbabilityToHit()).thenReturn(0.1666); Mockito.when(mockWeaponFireInfoPPC.getExpectedDamageOnHit()).thenReturn(10.0); Mockito.when(mockWeaponFireInfoPPC.getProbabilityToHit()).thenReturn(0.7222); Mockito.when(mockWeaponFireInfoERML.getExpectedDamageOnHit()).thenReturn(5.0); Mockito.when(mockWeaponFireInfoERML.getProbabilityToHit()).thenReturn(0.4166); double expected = (2 * 0.1666) + (10 * 0.7222) + (5 * 0.4166); Assert.assertEquals(expected, testFiringPlan.getExpectedDamage(), TOLERANCE); }
null); double damage = fireControl.determineBestFiringPlan(guess) .getExpectedDamage(); if (damage > max_damage) { max_damage = damage;
game, ammoConservation); if ((null != plan) && (plan.getExpectedDamage() > 0)) { getFireControl(shooter).loadAmmo(shooter, plan); plan.sortPlan(); final Double newDamage = damageMap.get(targetId) + plan.getExpectedDamage(); damageMap.replace(targetId,newDamage);
Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability(); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability(); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability(); Mockito.when(mockBehavior.getStrategicBuildingTargets()).thenReturn(testTargets); testFiringPlan = Mockito.spy(new FiringPlan(mockBuilding)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability(); Mockito.when(mockBuilding.getPosition()).thenReturn(new Coords(10, 10)); // A building not on the list. testFiringPlan = Mockito.spy(new FiringPlan(mockBuilding)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability(); Mockito.when(mockPrincess.getPriorityUnitTargets()).thenReturn(testPriorityUnits); testFiringPlan = Mockito.spy(new FiringPlan(mockTarget)); Mockito.doReturn(15.0).when(testFiringPlan).getExpectedDamage(); Mockito.doReturn(0.46129).when(testFiringPlan).getExpectedCriticals(); Mockito.doReturn(0.02005).when(testFiringPlan).getKillProbability();
modifier += calcPriorityUnitTargetUtility(firingPlan.getTarget()); double expectedDamage = firingPlan.getExpectedDamage(); double utility = 0; utility += DAMAGE_UTILITY * expectedDamage;