Skip to content

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

Merged
merged 7 commits into from
Jun 24, 2025

Conversation

peppy
Copy link
Member

@peppy peppy commented Jun 19, 2025

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.

peppy added 3 commits June 19, 2025 17:29
…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).
@peppy peppy force-pushed the fix-carousel-random-not-respecting-group branch from 2362c2a to 873d622 Compare June 19, 2025 08:29
@bdach bdach self-requested a review June 24, 2025 07:56
//
// 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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can hard crash:

  1. Start with any grouping mode chosen (as long as it's not off)
  2. Change to any other grouping mode (or turn grouping off)
  3. 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

Copy link
Member Author

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.

Copy link
Collaborator

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

Copy link
Member Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately 7b6ecbd reintroduced the crash in the "turn grouping off" case. See 0de964b.

I attempted a fix in 8781901. See if you buy it.

@peppy
Copy link
Member Author

peppy commented Jun 24, 2025

Yeah looks good, send it.

@bdach bdach merged commit a797c46 into ppy:master Jun 24, 2025
9 checks passed
@peppy peppy deleted the fix-carousel-random-not-respecting-group branch June 25, 2025 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Song Select v2: Random map select ignores group
2 participants