From 3c484b50407f546d5aba63e5e61202ec10d8b86d Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 6 Jul 2026 22:53:40 -0500 Subject: [PATCH] RSE: prefer swarm match special moves and hard to verify vblanks, just prefer the special move source first. I guess it's also the more statistically likely (players using swarms to catch the species that are much less common otherwise?) --- .../Generator/Search/EncounterEnumerator3.cs | 28 +++++++++--------- .../Subforms/SaveHandlerTroubleshooter.cs | 3 +- ... TEST - 5143F610D91A swarm lead matching.pk3 | Bin 0 -> 100 bytes 3 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 diff --git a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs index 6e375f042..e8e4e2adb 100644 --- a/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs +++ b/PKHeX.Core/Legality/Encounters/Generator/Search/EncounterEnumerator3.cs @@ -49,8 +49,8 @@ private enum YieldState : byte StartCaptures, SlotStart, - SlotR, SlotS, + SlotR, SlotE, SwarmRSE, SlotFR, @@ -74,6 +74,7 @@ private enum YieldState : byte public bool MoveNext() { + top: switch (State) { case YieldState.Start: @@ -145,33 +146,32 @@ public bool MoveNext() case YieldState.SlotStart: if (!EncounterStateUtil.CanBeWildEncounter(Entity)) goto case YieldState.SlotEnd; - if (Version == GameVersion.R) - { State = YieldState.SlotR; goto case YieldState.SlotR; } - if (Version == GameVersion.S) - { State = YieldState.SlotS; goto case YieldState.SlotS; } - if (Version == GameVersion.E) - { State = YieldState.SlotE; goto case YieldState.SlotE; } if (Version == GameVersion.FR) { State = YieldState.SlotFR; goto case YieldState.SlotFR; } if (Version == GameVersion.LG) { State = YieldState.SlotLG; goto case YieldState.SlotLG; } - throw new ArgumentOutOfRangeException(nameof(Version)); + if (Version is not (GameVersion.R or GameVersion.S or GameVersion.E)) + throw new ArgumentOutOfRangeException(nameof(Version)); + State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + + case YieldState.SwarmRSE: + // Aggressively check for Swarm (special move), only one match possible. Next loop will reach regular slots. + // higher priority due to having special move, and poor vblank matching deferral tiebreaks + if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) + return true; + Index = 0; State = YieldState.SlotS + (byte)((byte)Version - 1); Index = 0; goto top; case YieldState.SlotR: if (TryGetNext(Encounters3RSE.SlotsR)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotS: if (TryGetNext(Encounters3RSE.SlotsS)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; + Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotE: if (TryGetNext(Encounters3RSE.SlotsE)) return true; - Index = 0; State = YieldState.SwarmRSE; goto case YieldState.SwarmRSE; - case YieldState.SwarmRSE: - if (TryGetNext(Encounters3RSE.SlotsSwarmRSE)) - return true; Index = 0; goto case YieldState.SlotEnd; case YieldState.SlotFR: diff --git a/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs b/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs index f4f5fbf41..f34c22644 100644 --- a/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs +++ b/PKHeX.WinForms/Subforms/SaveHandlerTroubleshooter.cs @@ -37,8 +37,7 @@ private void InitializeBindings() var handlers = SaveUtil.Handlers.ToList(); handlers.Insert(0, new SaveHandlerDefault()); CB_Handler.DataSource = handlers - .Select(z => new HandlerItem(GetHandlerDisplayName(z), z)) - .ToList(); + .ConvertAll(z => new HandlerItem(GetHandlerDisplayName(z), z)); UpdateSubVersionChoices(); } diff --git a/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 b/Tests/PKHeX.Core.Tests/Legality/Legal/Generation 3/Misc/0283 ★ - TEST - 5143F610D91A swarm lead matching.pk3 new file mode 100644 index 0000000000000000000000000000000000000000..e0833b05fdf2f854bd21b2bbb08e54b2b9809a56 GIT binary patch literal 100 zcmb2TDe%qoi}meu`_G>H4+cz3$M+xKfA;@>2IoKq26ILR25AN$aARPY$dCkLG04e* dDFh+dtPofE-ySBw%pd@SYz*uSoD3X53;