-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn difficulty & performance attributes into structs #30727
Open
minisbett
wants to merge
17
commits into
ppy:master
Choose a base branch
from
minisbett:diff-pp-structs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e70f257
make performance attributes a struct
minisbett e88dff0
turn difficulty attributes into a struct
minisbett 6e2f8cf
Remove mods from difficulty attributes
minisbett ae25f27
fix usage of flashlight difficulty
minisbett d7ae4a0
Fix usages of IDifficultyAttributes
minisbett 4114ff5
Add tests
minisbett 109a5ad
merge master (broken state)
minisbett c5d5a5b
fix test issues
minisbett 11cb9e7
Fix beatmap attribute tests
minisbett b7ae152
remove empty constructors
minisbett aa5dba6
Add performance tests
minisbett 5a989ec
Fix xmldoc
minisbett 26e9c21
Fix code quality
minisbett d75eb3a
Return mods from `CalculateAllLegacyCombinations`
smoogipoo d12fd89
Rename empty attributes, make attributes json OptIn
minisbett 808d44d
Merge branch 'diff-pp-structs' of https://github.com/minisbett/osu in…
minisbett d6e5a47
Fix compile failures
bdach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.IO; | ||
using BenchmarkDotNet.Attributes; | ||
using osu.Framework.IO.Stores; | ||
using osu.Game.Beatmaps; | ||
using osu.Game.Beatmaps.Formats; | ||
using osu.Game.IO; | ||
using osu.Game.IO.Archives; | ||
using osu.Game.Rulesets; | ||
using osu.Game.Rulesets.Catch; | ||
using osu.Game.Rulesets.Difficulty; | ||
using osu.Game.Rulesets.Mania; | ||
using osu.Game.Rulesets.Osu; | ||
using osu.Game.Rulesets.Taiko; | ||
using osu.Game.Scoring; | ||
using osu.Game.Tests.Resources; | ||
|
||
namespace osu.Game.Benchmarks | ||
{ | ||
public class BenchmarkDifficultyCalculation : BenchmarkTest | ||
{ | ||
private FlatWorkingBeatmap beatmap = null!; | ||
|
||
private IDifficultyAttributes osuAttributes = null!; | ||
private IDifficultyAttributes taikoAttributes = null!; | ||
private IDifficultyAttributes catchAttributes = null!; | ||
private IDifficultyAttributes maniaAttributes = null!; | ||
|
||
public override void SetUp() | ||
{ | ||
using var resources = new DllResourceStore(typeof(TestResources).Assembly); | ||
using var archive = resources.GetStream("Resources/Archives/241526 Soleily - Renatus.osz"); | ||
using var zipReader = new ZipArchiveReader(archive); | ||
|
||
using var beatmapStream = new MemoryStream(); | ||
zipReader.GetStream("Soleily - Renatus (Gamu) [Insane].osu").CopyTo(beatmapStream); | ||
beatmapStream.Seek(0, SeekOrigin.Begin); | ||
var reader = new LineBufferedReader(beatmapStream); | ||
var decoder = Decoder.GetDecoder<Beatmap>(reader); | ||
|
||
beatmap = new FlatWorkingBeatmap(decoder.Decode(reader)); | ||
|
||
// Prepare difficulty attributes for an isolated performance calculation in every mode. | ||
osuAttributes = DifficultyOsu(); | ||
taikoAttributes = DifficultyTaiko(); | ||
catchAttributes = DifficultyCatch(); | ||
maniaAttributes = DifficultyMania(); | ||
} | ||
|
||
[Benchmark] | ||
public IDifficultyAttributes DifficultyOsu() => new OsuRuleset().CreateDifficultyCalculator(beatmap).Calculate(); | ||
|
||
[Benchmark] | ||
public IDifficultyAttributes DifficultyTaiko() => new TaikoRuleset().CreateDifficultyCalculator(beatmap).Calculate(); | ||
|
||
[Benchmark] | ||
public IDifficultyAttributes DifficultyCatch() => new CatchRuleset().CreateDifficultyCalculator(beatmap).Calculate(); | ||
|
||
[Benchmark] | ||
public IDifficultyAttributes DifficultyMania() => new ManiaRuleset().CreateDifficultyCalculator(beatmap).Calculate(); | ||
|
||
[Benchmark] | ||
public void PerformanceOsu() | ||
{ | ||
Ruleset ruleset = new OsuRuleset(); | ||
ScoreInfo score = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo); | ||
ruleset.CreatePerformanceCalculator()!.Calculate(score, osuAttributes); | ||
} | ||
|
||
[Benchmark] | ||
public void PerformanceTaiko() | ||
{ | ||
Ruleset ruleset = new TaikoRuleset(); | ||
ScoreInfo score = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo); | ||
ruleset.CreatePerformanceCalculator()!.Calculate(score, taikoAttributes); | ||
} | ||
|
||
[Benchmark] | ||
public void PerformanceCatch() | ||
{ | ||
Ruleset ruleset = new CatchRuleset(); | ||
ScoreInfo score = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo); | ||
ruleset.CreatePerformanceCalculator()!.Calculate(score, catchAttributes); | ||
} | ||
|
||
[Benchmark] | ||
public void PerformanceMania() | ||
{ | ||
Ruleset ruleset = new ManiaRuleset(); | ||
ScoreInfo score = new ScoreInfo(beatmap.BeatmapInfo, ruleset.RulesetInfo); | ||
ruleset.CreatePerformanceCalculator()!.Calculate(score, maniaAttributes); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 13 additions & 1 deletion
14
osu.Game.Rulesets.Catch/Difficulty/CatchPerformanceAttributes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using osu.Game.Rulesets.Difficulty; | ||
|
||
namespace osu.Game.Rulesets.Catch.Difficulty | ||
{ | ||
public class CatchPerformanceAttributes : PerformanceAttributes | ||
public struct CatchPerformanceAttributes : IPerformanceAttributes | ||
{ | ||
/// <summary> | ||
/// Calculated score performance points. | ||
/// </summary> | ||
[JsonProperty("pp")] | ||
public double Total { get; set; } | ||
|
||
public IEnumerable<PerformanceDisplayAttribute> GetAttributesForDisplay() | ||
{ | ||
yield return new PerformanceDisplayAttribute(nameof(Total), "Achieved PP", Total); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's that? why is it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute was previously defined on the class all attributes inherit from. Even though technically only the osu difficulty attributes need it right now, I decided to stick to how it was before.