Skip to content

Commit

Permalink
Programmatically generate greater offensive moves
Browse files Browse the repository at this point in the history
  • Loading branch information
shrianshChari committed Aug 29, 2024
1 parent 7b10263 commit ce50d5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
26 changes: 20 additions & 6 deletions stats/src/classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const Classifier = new class {
paralysis: PARALYSIS_MOVES,
confusion: CONFUSION_MOVES,
sleep: SLEEP_MOVES,
greaterOffensive: GREATER_OFFENSIVE_MOVES,
ohko: OHKO_MOVES,
} : this.caches[gen.num] || (this.caches[gen.num] = {
greaterSetup: computeGreaterSetupMoves(gen),
Expand All @@ -32,6 +33,7 @@ export const Classifier = new class {
paralysis: computeParalysisMoves(gen),
confusion: computeConfusionMoves(gen),
sleep: computeSleepMoves(gen),
greaterOffensive: computeGreaterOffensiveMoves(gen),
ohko: computeOHKOMoves(gen),
});

Expand Down Expand Up @@ -477,11 +479,6 @@ const LESSER_OFFENSIVE_MOVES = new Set([
'headcharge', 'wildcharge', 'takedown', 'dragonascent',
]);

const GREATER_OFFENSIVE_MOVES = new Set([
'selfdestruct', 'explosion', 'destinybond', 'perishsong',
'memento', 'healingwish', 'lunardance', 'finalgambit',
]);

function movesStallinessModifier(pokemon: PokemonSet<ID>, tables: {[name: string]: Set<ID>}) {
const moves = new Set(pokemon.moves as string[]);

Expand All @@ -505,7 +502,7 @@ function movesStallinessModifier(pokemon: PokemonSet<ID>, tables: {[name: string
if (pokemon.moves.some((m: ID) => tables.confusion.has(m))) mod += 0.5;
if (pokemon.moves.some((m: ID) => tables.sleep.has(m))) mod -= 0.5;
if (pokemon.moves.some((m: ID) => LESSER_OFFENSIVE_MOVES.has(m))) mod -= 0.5;
if (pokemon.moves.some((m: ID) => GREATER_OFFENSIVE_MOVES.has(m))) mod -= 1.0;
if (pokemon.moves.some((m: ID) => tables.greaterOffensive.has(m))) mod -= 1.0;
if (pokemon.moves.some((m: ID) => tables.ohko.has(m))) mod -= 1.0;

if (moves.has('bellydrum')) {
Expand Down Expand Up @@ -746,6 +743,23 @@ export function computeOHKOMoves(gen: Generation) {
);
}

export const GREATER_OFFENSIVE_MOVES = new Set([
'selfdestruct', 'explosion', 'destinybond', 'perishsong',
'memento', 'healingwish', 'lunardance', 'finalgambit',
] as ID[]);

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

const selfKOMoves = moves.filter(m => m.selfdestruct).map(m => m.id);

return new Set([
...selfKOMoves,
// These are moves that also deal with the user getting KOed
...(gen.num >= 2 ? ['destinybond', 'perishsong'] as ID[] : []),
]);
}

function targetsFoes(move: Move) {
return ['normal', 'adjacentFoe', 'allAdjacentFoes', 'foeSide'].includes(move.target);
}
5 changes: 5 additions & 0 deletions stats/src/test/classifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,9 @@ describe('Classifier', () => {
expect(getDifference(COMPUTED_OHKO_MOVES, classifier.OHKO_MOVES))
.toEqual(new Set(['horndrill']));
});
test('GREATER_OFFENSIVE_MOVES', () => {
const COMPUTED_GREATER_OFFENSIVE_MOVES = classifier.computeGreaterOffensiveMoves(GEN);

expect(COMPUTED_GREATER_OFFENSIVE_MOVES).toEqual(classifier.GREATER_OFFENSIVE_MOVES);
});
});

0 comments on commit ce50d5c

Please sign in to comment.