@pkmn/sim 0.5.14 → 0.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/config/formats.js +167 -174
- package/build/config/formats.js.map +1 -1
- package/build/data/aliases.js +2 -2
- package/build/data/aliases.js.map +1 -1
- package/build/data/conditions.js +4 -1
- package/build/data/conditions.js.map +1 -1
- package/build/data/formats-data.js +3 -3
- package/build/data/formats-data.js.map +1 -1
- package/build/data/items.js +5 -5
- package/build/data/items.js.map +1 -1
- package/build/data/learnsets.js +7 -6
- package/build/data/learnsets.js.map +1 -1
- package/build/data/mods/gen1/formats-data.js +1 -1
- package/build/data/mods/gen1/formats-data.js.map +1 -1
- package/build/data/mods/gen1/moves.js +1 -4
- package/build/data/mods/gen1/moves.js.map +1 -1
- package/build/data/mods/gen1/scripts.js +1 -1
- package/build/data/mods/gen1/scripts.js.map +1 -1
- package/build/data/mods/gen2/items.js +28 -0
- package/build/data/mods/gen2/items.js.map +1 -1
- package/build/data/mods/gen2/moves.js +2 -5
- package/build/data/mods/gen2/moves.js.map +1 -1
- package/build/data/mods/gen3/items.js +28 -0
- package/build/data/mods/gen3/items.js.map +1 -1
- package/build/data/mods/gen3/moves.js +0 -10
- package/build/data/mods/gen3/moves.js.map +1 -1
- package/build/data/mods/gen3/scripts.js +2 -2
- package/build/data/mods/gen3/scripts.js.map +1 -1
- package/build/data/mods/gen4/abilities.js +20 -0
- package/build/data/mods/gen4/abilities.js.map +1 -1
- package/build/data/mods/gen4/items.js +28 -0
- package/build/data/mods/gen4/items.js.map +1 -1
- package/build/data/mods/gen4/moves.js +17 -10
- package/build/data/mods/gen4/moves.js.map +1 -1
- package/build/data/mods/gen4/rulesets.js +2 -1
- package/build/data/mods/gen4/rulesets.js.map +1 -1
- package/build/data/mods/gen5/items.js +0 -4
- package/build/data/mods/gen5/items.js.map +1 -1
- package/build/data/mods/gen5/rulesets.js +2 -1
- package/build/data/mods/gen5/rulesets.js.map +1 -1
- package/build/data/mods/gen6/items.js +24 -0
- package/build/data/mods/gen6/items.js.map +1 -1
- package/build/data/mods/gen7/abilities.js +31 -0
- package/build/data/mods/gen7/abilities.js.map +1 -1
- package/build/data/mods/gen7/formats-data.js +4 -4
- package/build/data/mods/gen7/formats-data.js.map +1 -1
- package/build/data/mods/gen7/items.js +12 -0
- package/build/data/mods/gen7/items.js.map +1 -1
- package/build/data/mods/gen7/moves.js +14 -0
- package/build/data/mods/gen7/moves.js.map +1 -1
- package/build/data/mods/gen7/rulesets.js +2 -1
- package/build/data/mods/gen7/rulesets.js.map +1 -1
- package/build/data/moves.js +84 -91
- package/build/data/moves.js.map +1 -1
- package/build/data/pokedex.js +2 -2
- package/build/data/pokedex.js.map +1 -1
- package/build/data/rulesets.js +74 -4
- package/build/data/rulesets.js.map +1 -1
- package/build/data/tags.js +3 -3
- package/build/data/tags.js.map +1 -1
- package/build/data/text/items.js +1 -0
- package/build/data/text/items.js.map +1 -1
- package/build/data/text/moves.js +13 -11
- package/build/data/text/moves.js.map +1 -1
- package/build/sim/battle-actions.js +12 -4
- package/build/sim/battle-actions.js.map +1 -1
- package/build/sim/battle-queue.d.ts +2 -2
- package/build/sim/battle-queue.js +8 -0
- package/build/sim/battle-queue.js.map +1 -1
- package/build/sim/battle.js +85 -7
- package/build/sim/battle.js.map +1 -1
- package/build/sim/dex-conditions.d.ts +3 -2
- package/build/sim/dex-conditions.js.map +1 -1
- package/build/sim/dex-moves.d.ts +2 -1
- package/build/sim/dex-moves.js.map +1 -1
- package/build/sim/exported-global-types.d.ts +1 -0
- package/build/sim/global-types.d.ts +1 -0
- package/build/sim/pokemon.js +18 -5
- package/build/sim/pokemon.js.map +1 -1
- package/build/sim/team-validator.js +16 -5
- package/build/sim/team-validator.js.map +1 -1
- package/build/sim/tools/exhaustive-runner.d.ts +8 -0
- package/build/sim/tools/exhaustive-runner.js +18 -7
- package/build/sim/tools/exhaustive-runner.js.map +1 -1
- package/config/formats.ts +172 -179
- package/data/aliases.ts +2 -2
- package/data/conditions.ts +4 -1
- package/data/formats-data.ts +3 -3
- package/data/items.ts +5 -5
- package/data/learnsets.ts +7 -6
- package/data/mods/gen1/formats-data.ts +1 -1
- package/data/mods/gen1/moves.ts +1 -4
- package/data/mods/gen1/scripts.ts +1 -1
- package/data/mods/gen2/items.ts +28 -0
- package/data/mods/gen2/moves.ts +2 -5
- package/data/mods/gen3/items.ts +28 -0
- package/data/mods/gen3/moves.ts +0 -10
- package/data/mods/gen3/scripts.ts +3 -3
- package/data/mods/gen4/abilities.ts +20 -0
- package/data/mods/gen4/items.ts +28 -0
- package/data/mods/gen4/moves.ts +16 -11
- package/data/mods/gen4/rulesets.ts +2 -1
- package/data/mods/gen5/items.ts +0 -4
- package/data/mods/gen5/rulesets.ts +2 -1
- package/data/mods/gen6/items.ts +24 -0
- package/data/mods/gen7/abilities.ts +31 -0
- package/data/mods/gen7/formats-data.ts +4 -4
- package/data/mods/gen7/items.ts +12 -0
- package/data/mods/gen7/moves.ts +14 -0
- package/data/mods/gen7/rulesets.ts +2 -1
- package/data/moves.ts +84 -81
- package/data/pokedex.ts +2 -2
- package/data/rulesets.ts +73 -6
- package/data/tags.ts +3 -3
- package/data/text/items.ts +2 -0
- package/data/text/moves.ts +14 -11
- package/package.json +2 -2
- package/sim/battle-actions.ts +16 -5
- package/sim/battle-queue.ts +10 -2
- package/sim/battle.ts +81 -7
- package/sim/dex-conditions.ts +7 -2
- package/sim/dex-moves.ts +2 -1
- package/sim/exported-global-types.ts +3 -0
- package/sim/global-types.ts +3 -0
- package/sim/pokemon.ts +19 -7
- package/sim/team-validator.ts +17 -5
- package/sim/tools/exhaustive-runner.ts +29 -11
|
@@ -19,10 +19,18 @@ export interface ExhaustiveRunnerOptions {
|
|
|
19
19
|
maxGames?: number;
|
|
20
20
|
maxFailures?: number;
|
|
21
21
|
dual?: boolean | 'debug';
|
|
22
|
+
possible?: ExhaustiveRunnerPossibilites;
|
|
22
23
|
runner?: (options: RunnerOptions) => Promise<void>;
|
|
23
24
|
cmd?: (cycles: number, format: string, seed: string) => string;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
export interface ExhaustiveRunnerPossibilites {
|
|
28
|
+
pokemon?: ID[];
|
|
29
|
+
items?: ID[];
|
|
30
|
+
abilities?: ID[];
|
|
31
|
+
moves?: ID[];
|
|
32
|
+
}
|
|
33
|
+
|
|
26
34
|
export class ExhaustiveRunner {
|
|
27
35
|
static readonly DEFAULT_CYCLES = 1;
|
|
28
36
|
static readonly MAX_FAILURES = 10;
|
|
@@ -46,6 +54,7 @@ export class ExhaustiveRunner {
|
|
|
46
54
|
private readonly maxGames?: number;
|
|
47
55
|
private readonly maxFailures?: number;
|
|
48
56
|
private readonly dual: boolean | 'debug';
|
|
57
|
+
private readonly possible?: ExhaustiveRunnerPossibilites;
|
|
49
58
|
|
|
50
59
|
private readonly runner: (options: RunnerOptions) => Promise<void>;
|
|
51
60
|
private readonly cmd: (cycles: number, format: string, seed: string) => string;
|
|
@@ -63,6 +72,7 @@ export class ExhaustiveRunner {
|
|
|
63
72
|
this.maxFailures = options.maxFailures || ExhaustiveRunner.MAX_FAILURES;
|
|
64
73
|
this.dual = options.dual || false;
|
|
65
74
|
this.runner = options.runner || ((o: RunnerOptions) => new Runner(o).run());
|
|
75
|
+
this.possible = options.possible;
|
|
66
76
|
this.cmd = options.cmd || ((cycles: number, format: string, seed: string) =>
|
|
67
77
|
`node tools/simulate exhaustive --cycles=${cycles} --format=${format} --seed=${seed}`);
|
|
68
78
|
|
|
@@ -93,7 +103,7 @@ export class ExhaustiveRunner {
|
|
|
93
103
|
error: true,
|
|
94
104
|
});
|
|
95
105
|
|
|
96
|
-
if (this.log) this.logProgress(pools);
|
|
106
|
+
if (this.log) this.logProgress(dex, pools);
|
|
97
107
|
} catch (err) {
|
|
98
108
|
this.failures++;
|
|
99
109
|
console.error(
|
|
@@ -110,23 +120,31 @@ export class ExhaustiveRunner {
|
|
|
110
120
|
|
|
111
121
|
private createPools(dex: typeof Dex): Pools {
|
|
112
122
|
return {
|
|
113
|
-
pokemon: new Pool(
|
|
114
|
-
(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
pokemon: new Pool(this.possible?.pokemon ??
|
|
124
|
+
ExhaustiveRunner.onlyValid(dex.gen, dex.data.Pokedex, p => dex.species.get(p), (_, p) =>
|
|
125
|
+
(p.name !== 'Pichu-Spiky-eared' && p.name.substr(0, 8) !== 'Pikachu-')), this.prng),
|
|
126
|
+
items: new Pool(this.possible?.items ??
|
|
127
|
+
ExhaustiveRunner.onlyValid(dex.gen, dex.data.Items, i => dex.items.get(i)), this.prng),
|
|
128
|
+
abilities: new Pool(this.possible?.abilities ??
|
|
129
|
+
ExhaustiveRunner.onlyValid(dex.gen, dex.data.Abilities, a => dex.abilities.get(a)), this.prng),
|
|
130
|
+
moves: new Pool(this.possible?.moves ??
|
|
131
|
+
ExhaustiveRunner.onlyValid(dex.gen, dex.data.Moves, m => dex.moves.get(m), m =>
|
|
132
|
+
(m !== 'struggle' && (m === 'hiddenpower' || m.substr(0, 11) !== 'hiddenpower'))), this.prng),
|
|
119
133
|
};
|
|
120
134
|
}
|
|
121
135
|
|
|
122
|
-
private logProgress(p: Pools) {
|
|
136
|
+
private logProgress(dex: typeof Dex, p: Pools) {
|
|
123
137
|
// `\r` = return to the beginning of the line
|
|
124
138
|
// `\x1b[k` (`\e[K`) = clear all characters from cursor position to EOL
|
|
125
139
|
if (this.games) process.stdout.write('\r\x1b[K');
|
|
140
|
+
|
|
141
|
+
const msg = [`[${this.format}] P:${p.pokemon}`];
|
|
142
|
+
if (dex.gen >= 2) msg.push(`I:${p.items}`);
|
|
143
|
+
if (dex.gen >= 3) msg.push(`A:${p.abilities}`);
|
|
144
|
+
msg.push(`M:${p.moves} = ${this.games}`);
|
|
145
|
+
|
|
126
146
|
// Deliberately don't print a `\n` character so that we can overwrite
|
|
127
|
-
process.stdout.write(
|
|
128
|
-
`[${this.format}] P:${p.pokemon} I:${p.items} A:${p.abilities} M:${p.moves} = ${this.games}`
|
|
129
|
-
);
|
|
147
|
+
process.stdout.write(msg.join(' '));
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
private static getSignatures(dex: typeof Dex, pools: Pools): Map<string, {item: string, move?: string}[]> {
|