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;
|
2022-07-20 02:17:16 +08:00
|
|
|
using System.Collections.Generic;
|
2022-08-09 20:43:12 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2022-06-21 15:54:27 +08:00
|
|
|
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-08-09 20:43:12 +08:00
|
|
|
if (current.BaseObject is Spinner || current.Index == 0)
|
2022-06-21 20:15:31 +08:00
|
|
|
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-07-20 02:17:16 +08:00
|
|
|
List<DifficultyHitObject> pastVisibleObjects = retrievePastVisibleObjects(currObj);
|
|
|
|
List<DifficultyHitObject> currentVisibleObjects = retrieveCurrentVisibleObjects(currObj);
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
// Rather than note density being the number of on-screen objects visible at the current object,
|
|
|
|
// consider it as how many objects the current object has been visible for.
|
|
|
|
double noteDensity = 1.0;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
double loopOpacity = 1.0;
|
|
|
|
int previousIndex = 0;
|
2022-06-21 15:54:27 +08:00
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
while (loopOpacity > 0)
|
|
|
|
{
|
|
|
|
var loopObj = (OsuDifficultyHitObject)currObj.Previous(previousIndex);
|
2022-08-09 20:43:12 +08:00
|
|
|
|
|
|
|
if (loopObj.IsNull())
|
|
|
|
break;
|
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
loopOpacity = currObj.OpacityAt(loopObj.StartTime, false);
|
2022-08-09 20:43:12 +08:00
|
|
|
|
|
|
|
if (loopOpacity <= 0)
|
|
|
|
break;
|
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
noteDensity += loopOpacity;
|
|
|
|
previousIndex++;
|
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;
|
|
|
|
}
|
|
|
|
|
2022-07-20 02:17:16 +08:00
|
|
|
// Returns a list of objects that are visible on screen at
|
|
|
|
// the point in time at which the current object becomes visible.
|
|
|
|
private static List<DifficultyHitObject> retrievePastVisibleObjects(OsuDifficultyHitObject current)
|
|
|
|
{
|
|
|
|
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
|
|
|
|
|
|
|
|
for (int i = 0; i < current.Index; i++)
|
|
|
|
{
|
|
|
|
DifficultyHitObject currentObj = current.Previous(i);
|
|
|
|
|
|
|
|
if (current.OpacityAt(currentObj.StartTime, false) <= 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
objects.Add(currentObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
return objects;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns a list of objects that are visible on screen at
|
|
|
|
// the point in time at which the current object needs is clicked.
|
|
|
|
private static List<DifficultyHitObject> retrieveCurrentVisibleObjects(OsuDifficultyHitObject current)
|
|
|
|
{
|
|
|
|
List<DifficultyHitObject> objects = new List<DifficultyHitObject>();
|
|
|
|
|
|
|
|
for (int i = 0; i < current.Count; i++)
|
|
|
|
{
|
|
|
|
OsuDifficultyHitObject currentObj = (OsuDifficultyHitObject)current.Next(i);
|
|
|
|
|
2022-08-09 20:43:12 +08:00
|
|
|
if (currentObj.IsNull() || currentObj.OpacityAt(current.StartTime, false) <= 0)
|
2022-07-20 02:17:16 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
objects.Add(currentObj);
|
|
|
|
}
|
|
|
|
|
|
|
|
return objects;
|
|
|
|
}
|
|
|
|
|
2022-06-21 15:54:27 +08:00
|
|
|
private static double logistic(double x) => 1 / (1 + Math.Pow(Math.E, -x));
|
|
|
|
}
|
|
|
|
}
|