Skip to content

Commit

Permalink
Programmatically compute paralysis moves
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Aug 29, 2024
1 parent f0709c5 commit 177391f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
24 changes: 21 additions & 3 deletions stats/src/classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const Classifier = new class {
recovery: RECOVERY_MOVES,
protection: PROTECT_MOVES,
phazing: PHAZING_MOVES,
paralysis: PARALYSIS_MOVES,
} : this.caches[gen.num] || (this.caches[gen.num] = {
greaterSetup: computeGreaterSetupMoves(gen),
lesserSetup: computeLesserSetupMoves(gen),
Expand All @@ -25,6 +26,7 @@ export const Classifier = new class {
recovery: computeRecoveryMoves(gen),
protection: computeProtectionMoves(gen),
phazing: computePhazingMoves(gen),
paralysis: computeParalysisMoves(gen),
});

let teamBias = 0;
Expand Down Expand Up @@ -463,8 +465,6 @@ function itemStallinessModifier(pokemon: PokemonSet<ID>) {
return 0;
}

const PARALYSIS_MOVES = new Set(['thunderwave', 'stunspore', 'glare', 'nuzzle']);

const CONFUSION_MOVES = new Set([
'supersonic', 'confuseray', 'swagger', 'flatter', 'teeterdance', 'yawn',
]);
Expand Down Expand Up @@ -505,7 +505,7 @@ function movesStallinessModifier(pokemon: PokemonSet<ID>, tables: {[name: string
if (pokemon.moves.some((m: ID) => tables.recovery.has(m))) mod += 1.0;
if (pokemon.moves.some((m: ID) => tables.protection.has(m))) mod += 1.0;
if (pokemon.moves.some((m: ID) => tables.phazing.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => PARALYSIS_MOVES.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => tables.paralysis.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => CONFUSION_MOVES.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => SLEEP_MOVES.has(m))) mod -= 0.5;
if (pokemon.moves.some((m: ID) => LESSER_OFFENSIVE_MOVES.has(m))) mod -= 0.5;
Expand Down Expand Up @@ -679,6 +679,24 @@ export function computePhazingMoves(gen: Generation) {
);
}

export const PARALYSIS_MOVES = new Set(['thunderwave', 'stunspore', 'glare', 'nuzzle'] as ID[]);

export function computeParalysisMoves(gen: Generation) {
const moves = Array.from(gen.moves);

// Non-damaging moves that induce paralysis
const paralysisMoves = moves.filter(m => m.status && m.status === 'par').map(m => m.id);

// Attacking moves that are guaranteed to induce paralysis
const paralysisAttacks = moves.filter(m => m.secondary && m.secondary.status === 'par' &&
m.secondary.chance === 100 && m.accuracy === 100).map(m => m.id);

return new Set([
...paralysisMoves,
...paralysisAttacks,
]);
}

function targetsFoes(move: Move) {
return ['normal', 'adjacentFoe', 'allAdjacentFoes', 'foeSide'].includes(move.target);
}
6 changes: 6 additions & 0 deletions stats/src/test/classifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,10 @@ describe('Classifier', () => {

expect(COMPUTED_PHAZING_MOVES).toEqual(classifier.PHAZING_MOVES);
});

test('PARALYSIS_MOVES', () => {
const COMPUTED_PARALYSIS_MOVES = classifier.computeParalysisMoves(GEN);

expect(COMPUTED_PARALYSIS_MOVES).toEqual(classifier.PARALYSIS_MOVES);
});
});

0 comments on commit 177391f

Please sign in to comment.