reorder learnset by base power when randomizing

This commit is contained in:
Kurt
2018-06-19 21:28:39 -07:00
parent 2c44b57e13
commit da0f1f6eca
2 changed files with 18 additions and 4 deletions

View File

@@ -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<int> 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;
}

View File

@@ -91,6 +91,17 @@ private bool IsMovesetMeetingRequirements(int[] moves, int count)
return moves.Distinct().Count() == count;
}
public void ReorderMovesPower(IList<int> 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()