public int[] ScoreRound(List <PunchResult> punches, FightStats roundStats) { int[] roundScore = { 10 - roundStats.Knockdowns.Fighter1, 10 - roundStats.Knockdowns.Fighter2 }; //Auto lose round if knocked down- not strictly the rule but almost always works that way if (roundScore[0] > roundScore[1]) { roundScore[1]--; return(roundScore); } else if (roundScore[0] < roundScore[1]) { roundScore[0]--; return(roundScore); } //Ratio of fighter 1s sucessess to fighter 2s double combatRatio; //I added the plus 20 so that the damage ratio doesnt matter if nobody did any real damage double damageRatio = MathUtils.SafeDivide(roundStats.Damage.Fighter1 + 20, roundStats.Damage.Fighter2 + 20, 1, 10); damageRatio = Math.Pow(damageRatio, DamageWeight); double[] punchesIThinkLanded = { 0, 0 }; double[] cleanessSum = { 0, 0 }; foreach (PunchResult punch in punches) { int fighter = punch.ThrownBy; cleanessSum[fighter] += Math.Max(0, punch.Accuracy); if (punch.Accuracy >= IsLandedThreshold) { punchesIThinkLanded[fighter]++; } } double landedRatio = MathUtils.SafeDivide(punchesIThinkLanded[0], punchesIThinkLanded[1], 1, 10); landedRatio = Math.Pow(landedRatio, LandedWeight); double cleannessRatio = MathUtils.SafeDivide(cleanessSum[0], cleanessSum[1], 1, 10); cleannessRatio = Math.Pow(cleannessRatio, CleanessWeight); combatRatio = damageRatio * landedRatio * cleannessRatio; if (combatRatio > 1) { --roundScore[1]; } else if (combatRatio < 1) { --roundScore[0]; } return(roundScore); }
public void NextMinute() { if (Concluded) { throw new Exception("Fight already finished"); } int round = ++Minute / 3; Block block = new Block(this); var blockOutcome = block.Run(); FightStats blockStats = new FightStats(blockOutcome.Punches, block.Knockdowns[0], block.Knockdowns[1]); FightStats[round].Append(blockStats); Punches[round].AddRange(blockOutcome.Punches); if (blockOutcome.Stoppage != -1) { TimeOfStoppage = blockOutcome.Stoppage + Minute * 60; EndOfRound(); return; } F1.RecoverFor(60); F2.RecoverFor(60); if ((1 + Minute) % 3 == 0) { EndOfRound(); } }
public static FightStats Condense(this List <FightStats> list, bool useAverages = false) { FightStats summaryOfSummaries = new FightStats(); foreach (FightStats s in list) { summaryOfSummaries.Append(s); } if (useAverages) //Flawed due to integer rounding issues, used mostly for rounds - for testing only { summaryOfSummaries.Damage.Fighter1 /= list.Count; summaryOfSummaries.Damage.Fighter2 /= list.Count; summaryOfSummaries.Thrown.Fighter1 /= list.Count; summaryOfSummaries.Thrown.Fighter2 /= list.Count; summaryOfSummaries.Landed.Fighter1 /= list.Count; summaryOfSummaries.Landed.Fighter2 /= list.Count; summaryOfSummaries.Jabs.Fighter1 /= list.Count; summaryOfSummaries.Jabs.Fighter2 /= list.Count; } return(summaryOfSummaries); }