-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
SongSelectV2: Refine random selection to currently open group (and support difficulty split panels better) #33773
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
SongSelectV2: Refine random selection to currently open group (and support difficulty split panels better) #33773
Conversation
…aying individual difficulties Previously, random selection would always be done at a *set* level. The final operation of a random action would be "select the user's recommended difficulty from this randomly selected set". This makes no sense when sets are not grouped together at song select. In fact, it is completely broken with the previous commit which adds group-isolated random support – if we're grouping by difficulty and the user's recommendation is not in the current group it would throw the user into another group unexpectedly. This fixes the issue by splitting out the random implementation into two separate pathways depending on the carousel display mode.
Noticed in a flaky test with the changes to random, where the debounce may be delayed to the point of thinking the selection is invalid even though it's valid (timing woes, I cannot explain in words but I would highly recommend smiling and nodding approach).
2362c2a
to
873d622
Compare
// | ||
// If this becomes an issue, we could either store a mapping, or run the random algorithm many times | ||
// using the `SetItems` method until we get a group HIT. | ||
? grouping.GroupItems[ExpandedGroup].Select(i => i.Model).OfType<BeatmapInfo>().ToArray() |
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 can hard crash:
- Start with any grouping mode chosen (as long as it's not off)
- Change to any other grouping mode (or turn grouping off)
- Press random
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'GroupDefinition { Order = 2, Title = C }' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at osu.Game.Screens.SelectV2.BeatmapCarousel.nextRandomSet() in /Users/bdach/Documents/Work/open-source/osu/osu.Game/Screens/SelectV2/BeatmapCarousel.cs:line 724
at osu.Game.Screens.SelectV2.BeatmapCarousel.NextRandom() in /Users/bdach/Documents/Work/open-source/osu/osu.Game/Screens/SelectV2/BeatmapCarousel.cs:line 656
at osu.Game.Screens.SelectV2.SongSelect.<CreateFooterButtons>b__60_1() in /Users/bdach/Documents/Work/open-source/osu/osu.Game/Screens/SelectV2/SongSelect.cs:line 289
at osu.Game.Screens.SelectV2.FooterButtonRandom.<load>b__12_0() in /Users/bdach/Documents/Work/open-source/osu/osu.Game/Screens/SelectV2/FooterButtonRandom.cs:line 91
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.
Good catch. I believe this (and the second reported point of contention) should be fixed now.
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.
a1ec71e fixes the crash, sure. But in testing that same scenario of changing the grouping mode, I can now produce a situation wherein the random key can now switch to a completely different group after changing grouping modes, even if the selection hasn't changed:
Screen.Recording.2025-06-24.at.11.02.05.mov
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.
Sorry, made one more attempt.
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.
Yeah looks good, send it. |
The goal of this pull request was to fix the random button not respecting groups. But in the process of adding test coverage I noticed that I'd also need to fix a larger issue with random selection. The group fix change doesn't work well on its own so I've bundled these together.
Fix random button not respecting open group
Closes #33569.
Fix random selection not working as expected when displaying individual difficulties
Previously, random selection would always be done at a set level. The final operation of a random action would be "select the user's recommended difficulty from this randomly selected set".
This makes no sense when sets are not grouped together at song select. In fact, it is completely broken with the previous commit which adds group-isolated random support – if we're grouping by difficulty and the user's recommendation is not in the current group it would throw the user into another group unexpectedly.
This fixes the issue by splitting out the random implementation into two separate pathways depending on the carousel display mode.