mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 09:42:54 +08:00
Make hitProbability abstract
This commit is contained in:
parent
089b27d4d3
commit
266e6175d2
@ -5,6 +5,7 @@ using System;
|
||||
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Difficulty.Evaluators;
|
||||
using osu.Game.Rulesets.Osu.Difficulty.Utils;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
{
|
||||
@ -26,6 +27,14 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
private double skillMultiplier => 125;
|
||||
private double strainDecayBase => 0.15;
|
||||
|
||||
protected override double HitProbability(double skill, double difficulty)
|
||||
{
|
||||
if (skill <= 0) return 0;
|
||||
if (difficulty <= 0) return 1;
|
||||
|
||||
return SpecialFunctions.Erf(skill / (Math.Sqrt(2) * difficulty));
|
||||
}
|
||||
|
||||
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
|
||||
|
||||
protected override double StrainValueAt(DifficultyHitObject current)
|
||||
|
@ -34,26 +34,22 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
||||
difficulties.Add(StrainValueAt(current));
|
||||
}
|
||||
|
||||
private static double hitProbability(double skill, double difficulty)
|
||||
{
|
||||
if (skill <= 0) return 0;
|
||||
if (difficulty <= 0) return 1;
|
||||
protected abstract double HitProbability(double skill, double difficulty);
|
||||
|
||||
return SpecialFunctions.Erf(skill / (Math.Sqrt(2) * difficulty));
|
||||
}
|
||||
|
||||
private static double fcProbabilityAtSkill(double skill, IEnumerable<Bin> bins)
|
||||
private double fcProbabilityAtSkill(double skill, IEnumerable<Bin> bins)
|
||||
{
|
||||
if (skill <= 0) return 0;
|
||||
|
||||
return bins.Aggregate(1.0, (current, bin) => current * bin.FcProbability(skill));
|
||||
double totalHitProbability(Bin bin) => Math.Pow(HitProbability(skill, bin.Difficulty), bin.Count);
|
||||
|
||||
return bins.Aggregate(1.0, (current, bin) => current * totalHitProbability(bin));
|
||||
}
|
||||
|
||||
private double fcProbabilityAtSkill(double skill)
|
||||
{
|
||||
if (skill <= 0) return 0;
|
||||
|
||||
return difficulties.Aggregate<double, double>(1, (current, d) => current * hitProbability(skill, d));
|
||||
return difficulties.Aggregate<double, double>(1, (current, d) => current * HitProbability(skill, d));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1,17 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Difficulty.Utils
|
||||
{
|
||||
public struct Bin
|
||||
{
|
||||
public double Difficulty;
|
||||
public double Count;
|
||||
|
||||
public double HitProbability(double skill) => SpecialFunctions.Erf(skill / (Math.Sqrt(2) * Difficulty));
|
||||
|
||||
public double FcProbability(double skill) => Math.Pow(HitProbability(skill), Count);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user