mirror of
https://github.com/ppy/osu.git
synced 2025-03-13 19:47:30 +08:00
Slightly improve linq expressions
This commit is contained in:
parent
bb6c62c3aa
commit
778dfa701d
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
|||||||
|
|
||||||
private double? calculateAimError(IEnumerable<HitEvent> hitEvents, IBeatmap playableBeatmap)
|
private double? calculateAimError(IEnumerable<HitEvent> hitEvents, IBeatmap playableBeatmap)
|
||||||
{
|
{
|
||||||
IEnumerable<HitEvent> hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle));
|
IEnumerable<HitEvent> hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)).ToList();
|
||||||
|
|
||||||
double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit());
|
double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit());
|
||||||
double missCount = hitCircleEvents.Count() - nonMissCount;
|
double missCount = hitCircleEvents.Count() - nonMissCount;
|
||||||
@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
|||||||
// We don't get data for miss locations, so we estimate the total variance using the Rayleigh distribution.
|
// We don't get data for miss locations, so we estimate the total variance using the Rayleigh distribution.
|
||||||
// Deriving the Rayleigh distribution in this form results in a 2 in the denominator,
|
// Deriving the Rayleigh distribution in this form results in a 2 in the denominator,
|
||||||
// but it is removed to take the variance across both axes, instead of across just one.
|
// but it is removed to take the variance across both axes, instead of across just one.
|
||||||
double variance = (missCount * Math.Pow(radius, 2) + hitPoints.Aggregate(0.0, (current, point) => current + point.LengthSquared)) / nonMissCount;
|
double variance = (missCount * Math.Pow(radius, 2) + hitPoints.Sum(point => point.LengthSquared)) / nonMissCount;
|
||||||
|
|
||||||
return Math.Sqrt(variance) * 10;
|
return Math.Sqrt(variance) * 10;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.Statistics
|
|||||||
|
|
||||||
private double? calculateAverageAimError(IEnumerable<HitEvent> hitEvents)
|
private double? calculateAverageAimError(IEnumerable<HitEvent> hitEvents)
|
||||||
{
|
{
|
||||||
IEnumerable<HitEvent> hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle) && e.Result.IsHit());
|
IEnumerable<HitEvent> hitCircleEvents = hitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle) && e.Result.IsHit()).ToList();
|
||||||
|
|
||||||
double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit());
|
double nonMissCount = hitCircleEvents.Count(e => e.Result.IsHit());
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user