public double[] ExpectedTTKandTTD(Loadout enemyLoadout) { Weapon enemyWeapon = enemyLoadout.weapon; Target enemyTarget = enemyLoadout.target; double[] enemyProbabilities = enemyLoadout.probabilities; List <double> BTK = new List <double>(BTKDistribution.DistributionOfBulletsToKill(weapon, enemyTarget, probabilities)); BTK.Add(1 - BTK.Sum()); List <double> BTD = new List <double>(BTKDistribution.DistributionOfBulletsToKill(enemyWeapon, target, enemyProbabilities)); BTD.Add(1 - BTD.Sum()); int[] bulletTravelTimeMs = { (int)(enemyTarget.rangeFromShooterM / weapon.muzzleVelocityMpMs), (int)(target.rangeFromShooterM / enemyWeapon.muzzleVelocityMpMs) }; double[] expectedTTKandTTD = { 0, 0 }; for (int btk = 0; btk < BTK.Count; ++btk) { expectedTTKandTTD[0] += ((weapon.refireTime * (btk - 1)) + bulletTravelTimeMs[0]) * BTK[btk]; } for (int btd = 0; btd < BTD.Count; ++btd) { expectedTTKandTTD[1] += ((enemyWeapon.refireTime * (btd - 1)) + bulletTravelTimeMs[1]) * BTD[btd]; } return(expectedTTKandTTD); }
private void UpdateChartableTTKDist() { double[] TTKdist1 = BTKDistribution.DistributionOfBulletsToKill(loadout1.weapon, loadout2.target, loadout1.probabilities); ChartableTTKDist1.Clear(); if (sld_Range.Value > 0) { ChartableTTKDist1.Add(new KeyValuePair <int, double>(0, 0)); } for (int i = 1; i <= loadout1.weapon.magazineSize; ++i) { ChartableTTKDist1.Add(new KeyValuePair <int, double>(((i - 1) * loadout1.weapon.refireTime) + (int)(loadout2.target.rangeFromShooterM / loadout1.weapon.muzzleVelocityMpMs), TTKdist1[i])); } double[] TTKdist2 = BTKDistribution.DistributionOfBulletsToKill(loadout2.weapon, loadout1.target, loadout2.probabilities); ChartableTTKDist2.Clear(); if (sld_Range.Value > 0) { ChartableTTKDist2.Add(new KeyValuePair <int, double>(0, 0)); } for (int i = 1; i <= loadout2.weapon.magazineSize; ++i) { ChartableTTKDist2.Add(new KeyValuePair <int, double>(((i - 1) * loadout2.weapon.refireTime) + (int)(loadout1.target.rangeFromShooterM / loadout2.weapon.muzzleVelocityMpMs), TTKdist2[i])); } }
public double[] ProbWinsAgainst(Loadout enemyLoadout) { Weapon enemyWeapon = enemyLoadout.weapon; Target enemyTarget = enemyLoadout.target; double[] enemyProbabilities = enemyLoadout.probabilities; List <double> BTK = new List <double>(BTKDistribution.DistributionOfBulletsToKill(weapon, enemyTarget, probabilities)); BTK.Add(1 - BTK.Sum()); List <double> BTD = new List <double>(BTKDistribution.DistributionOfBulletsToKill(enemyWeapon, target, enemyProbabilities)); BTD.Add(1 - BTD.Sum()); int[] bulletTravelTimeMs = { (int)(enemyTarget.rangeFromShooterM / weapon.muzzleVelocityMpMs), (int)(target.rangeFromShooterM / enemyWeapon.muzzleVelocityMpMs) }; double[] ProbabilitiesOfPlayerWinning = { 0, 0, 0 }; for (int btk = 1; btk < BTK.Count; ++btk) { for (int btd = 1; btd < BTD.Count; ++btd) { // Both players still have ammo if (btk < BTK.Count - 1 && btd < BTD.Count - 1) { if ((btk - 1) * weapon.refireTime + bulletTravelTimeMs[0] < (btd - 1) * enemyWeapon.refireTime) { ProbabilitiesOfPlayerWinning[0] += BTK[btk] * BTD[btd]; } else if ((btk - 1) * weapon.refireTime > (btd - 1) * enemyWeapon.refireTime + bulletTravelTimeMs[1]) { ProbabilitiesOfPlayerWinning[1] += BTK[btk] * BTD[btd]; } //Kill trade else { ProbabilitiesOfPlayerWinning[2] += BTK[btk] * BTD[btd]; }; } // Enemy target has run out of bullets, this target still has ammo else if (btk < BTK.Count - 1 && btd == BTD.Count - 1) { ProbabilitiesOfPlayerWinning[0] += BTK[btk] * BTD[btd]; } // This target has run out of bullets, enemy still has ammo else if (btk == BTK.Count - 1 && btd < BTD.Count - 1) { ProbabilitiesOfPlayerWinning[1] += BTK[btk] * BTD[btd]; } // Both players are out of bullets else { // Do nothing, not a kill trade } } } return(ProbabilitiesOfPlayerWinning); }