From 91bfdc934fa52436991fbf71953f4a38edf44c71 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 15 Apr 2022 15:50:35 -0700 Subject: [PATCH] Allow multi oblivious (aggro+O) --- PermuteMMO.ConsoleApp/Program.cs | 2 +- PermuteMMO.Lib/Permutation/Advance.cs | 20 ++++++++++++++------ PermuteMMO.Lib/Permutation/PermuteResult.cs | 3 +++ PermuteMMO.Lib/Permuter.cs | 12 ++++++++---- PermuteMMO.Lib/SpawnState.cs | 4 +++- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/PermuteMMO.ConsoleApp/Program.cs b/PermuteMMO.ConsoleApp/Program.cs index 6224fd9..a9c2a2f 100644 --- a/PermuteMMO.ConsoleApp/Program.cs +++ b/PermuteMMO.ConsoleApp/Program.cs @@ -1,7 +1,7 @@ using PermuteMMO.Lib; // Change the criteria for emitting matches here. -PermuteMeta.SatisfyCriteria = (result, advances) => result.IsShiny; +PermuteMeta.SatisfyCriteria = (result, advances) => result.IsShiny && (advances.Count == 0 || result.Species is ((int)PKHeX.Core.Species.Basculin or (int)PKHeX.Core.Species.Basculegion)); // If a spawner json exists, spawn from that instead const string json = "spawner.json"; diff --git a/PermuteMMO.Lib/Permutation/Advance.cs b/PermuteMMO.Lib/Permutation/Advance.cs index 7568e3b..24e8bd7 100644 --- a/PermuteMMO.Lib/Permutation/Advance.cs +++ b/PermuteMMO.Lib/Permutation/Advance.cs @@ -12,7 +12,7 @@ public enum Advance : byte A1, A2, A3, A4, // Aggressive B1, B2, B3, B4, // Beta - O1, // Oblivious + O1, O2, O3, O4, // Oblivious // S1 is equivalent to B1 S2, S3, S4, @@ -49,6 +49,9 @@ public static class AdvanceExtensions B4 => "1 Beta + 3 Aggressive", O1 => "1 Oblivious", + O2 => "1 Oblivious + 1 Aggressive", + O3 => "1 Oblivious + 2 Aggressive", + O4 => "1 Oblivious + 3 Aggressive", G1 => "De-spawn 1 + Leave", G2 => "De-spawn 2 + Leave", @@ -65,17 +68,17 @@ public static class AdvanceExtensions /// public static int AdvanceCount(this Advance advance) => advance switch { - A1 or B1 or G1 => 1, - A2 or B2 or S2 or G2 => 2, - A3 or B3 or S3 or G3 => 3, - A4 or B4 or S4 => 4, + A1 or B1 or O1 or G1 => 1, + A2 or B2 or O1 or S2 or G2 => 2, + A3 or B3 or O1 or S3 or G3 => 3, + A4 or B4 or O1 or S4 => 4, _ => 0, }; /// /// Indicates if a multi-battle is required for this advancement. /// - public static bool IsMultiAny(this Advance advance) => advance.IsMultiAggressive() || advance.IsMultiBeta() || advance.IsMultiScare(); + public static bool IsMultiAny(this Advance advance) => advance.IsMultiAggressive() || advance.IsMultiBeta() || advance.IsMultiScare() || advance.IsMultiOblivious(); /// /// Indicates if a multi-battle is required for this advancement. @@ -92,6 +95,11 @@ public static class AdvanceExtensions /// public static bool IsMultiBeta(this Advance advance) => advance is (B2 or B3 or B4); + /// + /// Indicates if a multi-battle is required for this advancement. + /// + public static bool IsMultiOblivious(this Advance advance) => advance is (O2 or O3 or O4); + public static bool IsAny(this ReadOnlySpan span, Func check) { foreach (var x in span) diff --git a/PermuteMMO.Lib/Permutation/PermuteResult.cs b/PermuteMMO.Lib/Permutation/PermuteResult.cs index a657604..069292f 100644 --- a/PermuteMMO.Lib/Permutation/PermuteResult.cs +++ b/PermuteMMO.Lib/Permutation/PermuteResult.cs @@ -60,6 +60,9 @@ private static string GetFeasibility(ReadOnlySpan advances) return " -- Skittish: Mostly aggressive!"; } + if (advances.IsAny(AdvanceExtensions.IsMultiOblivious)) + return " -- Oblivious: Aggressive!"; + if (advances.IsAny(AdvanceExtensions.IsMultiAggressive)) return string.Empty; diff --git a/PermuteMMO.Lib/Permuter.cs b/PermuteMMO.Lib/Permuter.cs index 8024dfa..a24e358 100644 --- a/PermuteMMO.Lib/Permuter.cs +++ b/PermuteMMO.Lib/Permuter.cs @@ -81,10 +81,14 @@ private static void ContinuePermute(PermuteMeta meta, in ulong table, in ulong s if (state.AliveOblivious != 0) { - meta.Start(Advance.O1); - var newState = state.KnockoutOblivious(); - PermuteRecursion(meta, table, seed, newState); - meta.End(); + for (int i = 0; i <= state.AliveAggressive; i++) + { + var step = (int)Advance.O1 + i; + meta.Start((Advance)step); + var newState = state.KnockoutOblivious(i + 1); + PermuteRecursion(meta, table, seed, newState); + meta.End(); + } } // De-spawn: Single beta with aggressive(s) / none. diff --git a/PermuteMMO.Lib/SpawnState.cs b/PermuteMMO.Lib/SpawnState.cs index 4e251dd..6152b1d 100644 --- a/PermuteMMO.Lib/SpawnState.cs +++ b/PermuteMMO.Lib/SpawnState.cs @@ -59,11 +59,13 @@ public SpawnState KnockoutBeta(in int count) /// /// Returns a spawner state after knocking out existing entities. /// - public SpawnState KnockoutOblivious() + public SpawnState KnockoutOblivious(int count) { // Knock out required Aggressive var newOblivious = AliveOblivious - 1; + var newAggro = AliveAggressive - count + 1; Debug.Assert(newOblivious >= 0); + Debug.Assert(newAggro >= 0); return this with { Dead = Dead + 1, AliveOblivious = newOblivious }; }