1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-09 13:53:21 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Evaluators/CognitionEvaluator.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

77 lines
3.0 KiB
C#
Raw Normal View History

2022-06-21 15:54:27 +08:00
// 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;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Osu.Difficulty.Preprocessing;
2022-06-21 20:15:31 +08:00
using osu.Game.Rulesets.Osu.Objects;
2022-06-21 15:54:27 +08:00
namespace osu.Game.Rulesets.Osu.Difficulty.Evaluators
{
public static class CognitionEvaluator
{
public static double EvaluateDifficultyOf(DifficultyHitObject current, bool hidden)
{
2022-06-21 20:15:31 +08:00
if (current.BaseObject is Spinner)
return 0;
2022-06-21 15:54:27 +08:00
var currObj = (OsuDifficultyHitObject)current;
2022-06-22 06:21:57 +08:00
double currVelocity = currObj.LazyJumpDistance / currObj.StrainTime;
2022-06-21 15:54:27 +08:00
2022-06-22 06:21:57 +08:00
double noteDensity = 1.0;
2022-06-21 15:54:27 +08:00
// This loop sucks so much lol.
// Will be replaced in conjuction with the "objects with current visible" and the "currently visible objects" lists
// Also variable names like opacity and note density don't seem accurate anymore :face_with_monocole:...
2022-06-21 20:15:31 +08:00
for (int i = 0; i < 100; i++)
2022-06-21 15:54:27 +08:00
{
2022-06-21 20:15:31 +08:00
if (currObj.Next(i + 1).IsNull())
break;
var currLoopObj = (OsuDifficultyHitObject)currObj.Next(i);
var nextLoopObj = (OsuDifficultyHitObject)currObj.Next(i + 1);
double opacity = currLoopObj.OpacityAt(currObj.BaseObject.StartTime, false);
if (opacity == 0)
2022-06-21 15:54:27 +08:00
break;
2022-06-21 20:15:31 +08:00
// Small distances means objects may be cheesed, so it doesn't matter whether they are arranged confusingly.
opacity *= logistic((currLoopObj.MinimumJumpDistance - 100) / 15);
2022-06-21 15:54:27 +08:00
2022-06-21 20:15:31 +08:00
// Objects that are arranged in a mostly-linear fashion should be easy to read (such as circles in a stream).
if (nextLoopObj.Angle.IsNotNull())
opacity *= 1 - Math.Pow(Math.Sin(0.5 * nextLoopObj.Angle.Value), 5);
2022-06-21 15:54:27 +08:00
2022-06-21 20:15:31 +08:00
noteDensity += opacity;
2022-06-21 15:54:27 +08:00
}
2022-06-24 22:48:50 +08:00
double noteDensityDifficulty = Math.Pow(Math.Max(0, noteDensity - 2), 2);
2022-06-22 06:21:57 +08:00
double hiddenDifficulty = 0;
2022-06-21 15:54:27 +08:00
if (hidden)
2022-06-22 06:21:57 +08:00
{
noteDensityDifficulty *= 3.2;
2022-06-21 15:54:27 +08:00
2022-06-22 06:21:57 +08:00
// Really not sure about this, but without this a lot of normal HD plays become underweight.
2022-06-24 22:48:50 +08:00
hiddenDifficulty = 7 * currObj.LazyJumpDistance / currObj.StrainTime;
2022-06-22 06:21:57 +08:00
}
2022-06-21 15:54:27 +08:00
double preemptDifficulty = 0.0;
if (currObj.preempt < 400)
2022-06-22 06:21:57 +08:00
preemptDifficulty += Math.Pow(400 - currObj.preempt, 1.5) / 14;
// Buff rhythm on high AR.
preemptDifficulty *= RhythmEvaluator.EvaluateDifficultyOf(current, 30);
2022-06-21 15:54:27 +08:00
2022-06-22 06:21:57 +08:00
double difficulty = Math.Max(preemptDifficulty, hiddenDifficulty) + noteDensityDifficulty;
2022-06-21 15:54:27 +08:00
return difficulty;
}
private static double logistic(double x) => 1 / (1 + Math.Pow(Math.E, -x));
}
}