Skip to content

Commit

Permalink
prevent singles from getting stuck on the edges
Browse files Browse the repository at this point in the history
  • Loading branch information
hwabis committed Jan 17, 2025
1 parent 0fef0d4 commit d870c47
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// 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;
using System.Collections.Generic;
using System.Threading;
using osu.Game.Beatmaps;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public class PumpTrainerHitObjectGenerator
private PumpTrainerHitObjectGeneratorSettingsPerHitObject perHitObjectsettings;

private int fullDoublesEdgeStreak = 0;
private int p1SinglesEdgeStreak = 0;

public PumpTrainerHitObjectGenerator()
{
Expand Down Expand Up @@ -152,7 +153,7 @@ private Column getNextColumn(Foot nextFoot, Column previousColumn)
banColumnsCausingBannedPatterns(candidateColumns, nextFoot == Foot.Left ? Foot.Right : Foot.Left);
}

return getRandomCandidateColumn(candidateColumns);
return getRandomCandidateColumnWeighted(candidateColumns);
}

private List<Column> getCandidateColumns(Foot nextFoot, Column previousColumn, bool maximizeCandidateCount)
Expand Down Expand Up @@ -576,7 +577,7 @@ private void banColumnsCausingBannedPatterns(List<Column> candidateColumns, Foot
}
}

private Column getRandomCandidateColumn(List<Column> candidateColumns)
private Column getRandomCandidateColumnWeighted(List<Column> candidateColumns)
{
if (candidateColumns.Count == 0)
{
Expand Down Expand Up @@ -604,23 +605,41 @@ private Column getRandomCandidateColumn(List<Column> candidateColumns)
}
}

// If full-doubles, increase the likelihood of the half-doubles area,
// especially if there's an edge streak going on
// If full-doubles, decrease the likelihood of a panel on the same column as the previous if on the edge
if (Settings.AllowedColumns.Count == 10 &&
columnToPhysicalColumn[candidateColumn] >= 1 && columnToPhysicalColumn[candidateColumn] <= 4)
fullDoublesEdgeStreak > 0 &&
previousColumn != null &&
columnToPhysicalColumn[candidateColumn] != columnToPhysicalColumn[previousColumn.Value])
{
for (int i = 0; i < 4 * fullDoublesEdgeStreak; i++)
{
candidateColumnsWeighted.Add(candidateColumn);
}
}

// Also apply for singles
if (Settings.AllowedColumns.SequenceEqual([Column.P1DL, Column.P1UL, Column.P1C, Column.P1UR, Column.P1DR]) &&
p1SinglesEdgeStreak > 0 &&
previousColumn != null &&
columnToPhysicalColumn[candidateColumn] != columnToPhysicalColumn[previousColumn.Value])
{
for (int i = 0; i < 4 * p1SinglesEdgeStreak; i++)
{
candidateColumnsWeighted.Add(candidateColumn);
}
}
}

Column selectedColumn = candidateColumnsWeighted[random.Next(candidateColumnsWeighted.Count)];

fullDoublesEdgeStreak = columnToPhysicalColumn[selectedColumn] == 0 || columnToPhysicalColumn[selectedColumn] == 5 ?
fullDoublesEdgeStreak =
columnToPhysicalColumn[selectedColumn] == 0 || columnToPhysicalColumn[selectedColumn] == 5 ?
fullDoublesEdgeStreak + 1 : 0;

p1SinglesEdgeStreak =
columnToPhysicalColumn[selectedColumn] == 0 || columnToPhysicalColumn[selectedColumn] == 2 ?
p1SinglesEdgeStreak + 1 : 0;

return selectedColumn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected override void UpdateHitStateTransforms(ArmedState state)
switch (state)
{
case ArmedState.Hit:
this.FadeOut().Expire(); // todo i guess
this.FadeOut().Expire();
break;

case ArmedState.Miss:
Expand Down

0 comments on commit d870c47

Please sign in to comment.