From da0f1f6eca0c76eeb11a1ade8d35b9dc87389179 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 19 Jun 2018 21:28:39 -0700 Subject: [PATCH] reorder learnset by base power when randomizing --- pk3DS.Core/Randomizers/LearnsetRandomizer.cs | 9 ++++++--- pk3DS.Core/Randomizers/MoveRandomizer.cs | 13 ++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs index 74b3890..3303cb6 100644 --- a/pk3DS.Core/Randomizers/LearnsetRandomizer.cs +++ b/pk3DS.Core/Randomizers/LearnsetRandomizer.cs @@ -6,8 +6,8 @@ namespace pk3DS.Core.Randomizers { // https://twitter.com/Drayano60/status/807297858244411397 - // ORAS: 10682 moves learned on levelup/birth. - // 5593 are STAB. 52.3% are STAB. + // ORAS: 10682 moves learned on levelup/birth. + // 5593 are STAB. 52.3% are STAB. // Steelix learns the most @ 25 (so many level 1)! // Move relearner ingame glitch fixed (52 tested), but keep below 75 public class LearnsetRandomizer : IRandomizer @@ -30,11 +30,12 @@ public LearnsetRandomizer(GameConfig config, Learnset[] sets) public int SpreadTo = 75; public bool STABFirst = true; public bool Learn4Level1 = false; + public bool OrderByPower = true; public bool STAB { set => moverand.rSTAB = value; } public IList BannedMoves { set => moverand.BannedMoves = value; } public decimal rSTABPercent { set => moverand.rSTABPercent = value; } - + public void Execute() { for (var i = 0; i < Learnsets.Length; i++) @@ -91,6 +92,8 @@ private int[] GetRandomMoves(int count, int index) // STAB Moves (if requested) come first; randomize the order of moves Util.Shuffle(rand); + if (OrderByPower) + moverand.ReorderMovesPower(rand); rand.CopyTo(moves, 1); return moves; } diff --git a/pk3DS.Core/Randomizers/MoveRandomizer.cs b/pk3DS.Core/Randomizers/MoveRandomizer.cs index 5225763..7f0a69e 100644 --- a/pk3DS.Core/Randomizers/MoveRandomizer.cs +++ b/pk3DS.Core/Randomizers/MoveRandomizer.cs @@ -91,6 +91,17 @@ private bool IsMovesetMeetingRequirements(int[] moves, int count) return moves.Distinct().Count() == count; } + public void ReorderMovesPower(IList moves) + { + var data = moves.Select((Move, Index) => new {Index, Move, Data = MoveData[Move]}); + var powered = data.Where(z => z.Data.Power > 1).ToList(); + var indexes = powered.Select(z => z.Index).ToList(); + var order = powered.OrderBy(z => z.Data.Power * Math.Max(1, (z.Data.HitMin + z.Data.HitMax)/2m)).ToList(); + + for (var i = 0; i < order.Count; i++) + moves[indexes[i]] = order[i].Move; + } + private static readonly int[] firstMoves = { 1, // Pound @@ -103,7 +114,7 @@ private bool IsMovesetMeetingRequirements(int[] moves, int count) 98, // Quick Attack 122, // Lick 141, // Leech Life - + }; private static readonly GenericRandomizer first = new GenericRandomizer(firstMoves); public int GetRandomFirstMoveAny()