Skip to content

Commit

Permalink
Allow multi oblivious (aggro+O)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwsch committed Apr 15, 2022
1 parent e7cdced commit 91bfdc9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion PermuteMMO.ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
20 changes: 14 additions & 6 deletions PermuteMMO.Lib/Permutation/Advance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -65,17 +68,17 @@ public static class AdvanceExtensions
/// </summary>
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,
};

/// <summary>
/// Indicates if a multi-battle is required for this advancement.
/// </summary>
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();

/// <summary>
/// Indicates if a multi-battle is required for this advancement.
Expand All @@ -92,6 +95,11 @@ public static class AdvanceExtensions
/// </summary>
public static bool IsMultiBeta(this Advance advance) => advance is (B2 or B3 or B4);

/// <summary>
/// Indicates if a multi-battle is required for this advancement.
/// </summary>
public static bool IsMultiOblivious(this Advance advance) => advance is (O2 or O3 or O4);

public static bool IsAny<T>(this ReadOnlySpan<T> span, Func<T, bool> check)
{
foreach (var x in span)
Expand Down
3 changes: 3 additions & 0 deletions PermuteMMO.Lib/Permutation/PermuteResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ private static string GetFeasibility(ReadOnlySpan<Advance> advances)
return " -- Skittish: Mostly aggressive!";
}

if (advances.IsAny(AdvanceExtensions.IsMultiOblivious))
return " -- Oblivious: Aggressive!";

if (advances.IsAny(AdvanceExtensions.IsMultiAggressive))
return string.Empty;

Expand Down
12 changes: 8 additions & 4 deletions PermuteMMO.Lib/Permuter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion PermuteMMO.Lib/SpawnState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ public SpawnState KnockoutBeta(in int count)
/// <summary>
/// Returns a spawner state after knocking out existing entities.
/// </summary>
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 };
}

Expand Down

0 comments on commit 91bfdc9

Please sign in to comment.