Skip to content

Commit

Permalink
YEP
Browse files Browse the repository at this point in the history
  • Loading branch information
Loloppe committed Apr 22, 2023
1 parent 4fe722f commit 9a8c4d5
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 246 deletions.
319 changes: 133 additions & 186 deletions BeatSaber_BeatmapScanner/Algorithm/LackWiz/Method.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions BeatSaber_BeatmapScanner/Algorithm/Loloppe/BeatmapScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static (double diff, double tech, double ebpm, double slider, double rese

if (red.Count() > 0)
{
Helper.FindNoteDirection(red, bombs, bpm);
Helper.FindNoteDirection(red, bombs);
Helper.FixPatternHead(red);
Helper.FindReset(red);
ebpm = GetEBPM(red, bpm);
Expand All @@ -60,14 +60,14 @@ public static (double diff, double tech, double ebpm, double slider, double rese

if (blue.Count() > 0)
{
Helper.FindNoteDirection(blue, bombs, bpm);
Helper.FindNoteDirection(blue, bombs);
Helper.FixPatternHead(blue);
Helper.FindReset(blue);
ebpm = Math.Max(GetEBPM(blue, bpm), ebpm);
Helper.CalculateDistance(blue);
}

(pass, tech, data) = Method.UseLackWizAlgorithm(red.Select(c => c.Note).ToList(), blue.Select(c => c.Note).ToList(), bpm);
(pass, tech, data) = Method.UseLackWizAlgorithm(red, blue, bpm);

#endregion

Expand Down
4 changes: 2 additions & 2 deletions BeatSaber_BeatmapScanner/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyVersion("1.3.1")]
[assembly: AssemblyFileVersion("1.3.1")]
6 changes: 3 additions & 3 deletions BeatSaber_BeatmapScanner/Settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ internal class Settings
public virtual float DColorA { get; set; } = 5f;
public virtual float DColorB { get; set; } = 7f;
public virtual float DColorC { get; set; } = 9f;
public virtual float TColorA { get; set; } = 2f;
public virtual float TColorB { get; set; } = 3f;
public virtual float TColorC { get; set; } = 4f;
public virtual float TColorA { get; set; } = 5f;
public virtual float TColorB { get; set; } = 7f;
public virtual float TColorC { get; set; } = 9f;
public virtual Vector3 UIPosition { get; set; } = new(2f, 2.9f, 3.7f);
public virtual Quaternion UIRotation { get; set; } = Quaternion.Euler(new Vector3(350, 28, 360));

Expand Down
6 changes: 3 additions & 3 deletions BeatSaber_BeatmapScanner/UI/Views/settings.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
<text text='Tech color steps' align='Center'/>
</horizontal>
<slider-setting apply-on-change="true" value="TColorA" text="Mid value"
min="0" max="2" increment="0.05"/>
min="0" max="20" increment="0.5"/>
<slider-setting apply-on-change="true" value="TColorB" text="High value"
min="0" max="2" increment="0.05"/>
min="0" max="20" increment="0.5"/>
<slider-setting apply-on-change="true" value="TColorC" text="Extreme value"
min="0" max="2" increment="0.05"/>
min="0" max="20" increment="0.5"/>
</settings-container>
96 changes: 48 additions & 48 deletions BeatSaber_BeatmapScanner/Utils/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,70 @@ public static void SwapValue(List<Cube> list, int indexA, int indexB)
(list[indexB].Reset, list[indexA].Reset) = (list[indexA].Reset, list[indexB].Reset);
}

public static double Mod(double x, double m)
{
return (x % m + m) % m;
}

public static void FixPatternHead(List<Cube> cubes)
{
for (int j = 0; j < 3; j++)
{
for (int i = 1; i < cubes.Count(); i++)
for (int i = 1; i < cubes.Count() - 1; i++)
{
double temp = DirectionToDegree[(int)cubes[i].Note.cutDirection] + cubes[i].Note.angleOffset;

if ((int)cubes[i].Note.cutDirection == 8)
{
if (cubes[i].Beat - cubes[i - 1].Beat <= 0.02 && cubes[i].Beat - cubes[i - 1].Beat >= -0.02)
{
if ((int)cubes[i - 1].Note.cutDirection != 8)
{
temp = DirectionToDegree[(int)cubes[i - 1].Note.cutDirection] + cubes[i - 1].Note.angleOffset;
}
}
if (cubes[i + 1].Beat - cubes[i].Beat <= 0.02 && cubes[i + 1].Beat - cubes[i].Beat >= -0.02)
{
if ((int)cubes[i + 1].Note.cutDirection != 8)
{
temp = DirectionToDegree[(int)cubes[i + 1].Note.cutDirection] + cubes[i + 1].Note.angleOffset;
}
}
}

if (cubes[i].Note.beat == cubes[i - 1].Note.beat)
{
switch (cubes[i - 1].Direction)
switch (temp)
{
case 0:
case double d when (d > 67.5 && d <= 112.5):
if (cubes[i - 1].Layer > cubes[i].Layer)
{
Swap(cubes, i - 1, i);
SwapValue(cubes, i - 1, i);
}
break;
case 1:
case double d when (d > 247.5 && d <= 292.5):
if (cubes[i - 1].Layer < cubes[i].Layer)
{
Swap(cubes, i - 1, i);
SwapValue(cubes, i - 1, i);
}
break;
case 2:
case double d when (d > 157.5 && d <= 202.5):
if (cubes[i - 1].Line < cubes[i].Line)
{
Swap(cubes, i - 1, i);
SwapValue(cubes, i - 1, i);
}
break;
case 3:
case double d when ((d <= 22.5 && d >= 0) || (d > 337.5 && d < 360)):
if (cubes[i - 1].Line > cubes[i].Line)
{
Swap(cubes, i - 1, i);
SwapValue(cubes, i - 1, i);
}
break;
case 4:
case double d when (d > 112.5 && d <= 157.5):
if (cubes[i - 1].Line < cubes[i].Line)
{
Swap(cubes, i - 1, i);
Expand All @@ -75,7 +100,7 @@ public static void FixPatternHead(List<Cube> cubes)
SwapValue(cubes, i - 1, i);
}
break;
case 5:
case double d when (d > 22.5 && d <= 67.5):
if (cubes[i - 1].Line > cubes[i].Line)
{
Swap(cubes, i - 1, i);
Expand All @@ -87,7 +112,7 @@ public static void FixPatternHead(List<Cube> cubes)
SwapValue(cubes, i - 1, i);
}
break;
case 6:
case double d when (d > 202.5 && d <= 247.5):
if (cubes[i - 1].Line < cubes[i].Line)
{
Swap(cubes, i - 1, i);
Expand All @@ -99,7 +124,7 @@ public static void FixPatternHead(List<Cube> cubes)
SwapValue(cubes, i - 1, i);
}
break;
case 7:
case double d when (d > 292.5 && d <= 337.5):
if (cubes[i - 1].Line > cubes[i].Line)
{
Swap(cubes, i - 1, i);
Expand Down Expand Up @@ -136,15 +161,15 @@ public static void FindReset(List<Cube> cubes)

public static bool IsSameDirection(double before, double after)
{
if (before - after <= 180)
if (Math.Abs(before - after) <= 180)
{
var diff = Math.Abs(before - after);
if (diff <= 67.5)
{
return true;
}
}
else if (before - after > 180)
else if (Math.Abs(before - after) > 180)
{
var diff = 360 - Math.Abs(before - after);
if (diff <= 67.5)
Expand All @@ -156,24 +181,21 @@ public static bool IsSameDirection(double before, double after)
return false;
}

public static void FindNoteDirection(List<Cube> cubes, List<BombNoteData> bombs, float bpm)
public static void FindNoteDirection(List<Cube> cubes, List<BombNoteData> bombs)
{
if (cubes[0].Assumed)
if ((int)cubes[0].Note.cutDirection == 8)
{
var c = cubes.Where(ca => !ca.Assumed).FirstOrDefault();
var c = cubes.Where(ca => (int)ca.Note.cutDirection != 8).FirstOrDefault();
if (c != null)
{
double temp = 270;
for (int i = 0; i < cubes.IndexOf(c); i++)
cubes[0].Direction = DirectionToDegree[(int)c.Note.cutDirection] + c.Note.angleOffset;
for (int i = cubes.IndexOf(c); i > 1; i--)
{
var a = DirectionToDegree[(int)c.Note.cutDirection] + c.Note.angleOffset;
if (a >= 360)
if (cubes[i].Beat - cubes[i - 1].Beat >= 0.25)
{
a -= 180;
cubes[0].Direction = Helper.ReverseCutDirection(cubes[0].Direction);
}
temp = ReverseCutDirection(a);
}
cubes[0].Direction = temp;
}
else
{
Expand All @@ -189,12 +211,7 @@ public static void FindNoteDirection(List<Cube> cubes, List<BombNoteData> bombs,
}
else
{
var a = DirectionToDegree[(int)cubes[0].Note.cutDirection] + cubes[0].Note.angleOffset;
if (a >= 360)
{
a -= 180;
}
cubes[0].Direction = a;
cubes[0].Direction = DirectionToDegree[(int)cubes[0].Note.cutDirection] + cubes[0].Note.angleOffset;
}

bool pattern = false;
Expand Down Expand Up @@ -240,7 +257,7 @@ public static void FindNoteDirection(List<Cube> cubes, List<BombNoteData> bombs,

if (cubes[i].Assumed && !cubes[i].Pattern && !cubes[i].Bomb)
{
cubes[i].Direction = ReverseCutDirection((int)cubes[i - 1].Direction);
cubes[i].Direction = ReverseCutDirection(cubes[i - 1].Direction);
}
else if (cubes[i].Assumed && cubes[i].Pattern)
{
Expand Down Expand Up @@ -270,12 +287,7 @@ public static void FindNoteDirection(List<Cube> cubes, List<BombNoteData> bombs,
}
else
{
var a = DirectionToDegree[(int)cubes[i].Note.cutDirection] + cubes[i].Note.angleOffset;
if (a >= 360)
{
a -= 180;
}
cubes[i].Direction = a;
cubes[i].Direction = DirectionToDegree[(int)cubes[i].Note.cutDirection] + cubes[i].Note.angleOffset;
}
}
}
Expand Down Expand Up @@ -313,15 +325,7 @@ public static bool IsInLinearPath(Cube previous, Cube current, Cube next)
{
var prev = CalculateBaseEntryExit((previous.Line, previous.Layer), previous.Direction);
var curr = CalculateBaseEntryExit((current.Line, current.Layer), current.Direction);
((double x, double y) entry, (double x, double y) exit) nxt;
if (IsSameDirection(previous.Direction, next.Direction))
{
nxt = CalculateBaseEntryExit((next.Line, next.Layer), previous.Direction);
}
else
{
nxt = CalculateBaseEntryExit((next.Line, next.Layer), next.Direction);
}
var nxt = CalculateBaseEntryExit((next.Line, next.Layer), next.Direction);

var dxc = nxt.entry.x - prev.entry.x;
var dyc = nxt.entry.y - prev.entry.y;
Expand Down Expand Up @@ -352,10 +356,6 @@ public static void CalculateDistance(List<Cube> cubes)
{
if (!cubes[i].Pattern || cubes[i].Head)
{
// var prev = CalculateBaseEntryExit((pre.Line, pre.Layer), pre.Direction);
// var now = CalculateBaseEntryExit((cubes[i].Line, cubes[i].Layer), cubes[i].Direction);
// var distance = Math.Sqrt(Math.Pow(now.exit.x - prev.entry.x, 2) + Math.Pow(now.exit.y - prev.entry.y, 2));

if (IsInLinearPath(pre2, pre, cubes[i]))
{
cubes[i].Linear = true;
Expand Down
2 changes: 1 addition & 1 deletion BeatSaber_BeatmapScanner/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "BeatmapScanner",
"name": "BeatmapScanner",
"author": "Loloppe",
"version": "1.3.0",
"version": "1.3.1",
"description": "Analyze the difficulty of a beatmap",
"gameVersion": "1.29.1",
"dependsOn": {
Expand Down

0 comments on commit 9a8c4d5

Please sign in to comment.