@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.
Files changed (127) hide show
  1. package/build/config/formats.js +167 -174
  2. package/build/config/formats.js.map +1 -1
  3. package/build/data/aliases.js +2 -2
  4. package/build/data/aliases.js.map +1 -1
  5. package/build/data/conditions.js +4 -1
  6. package/build/data/conditions.js.map +1 -1
  7. package/build/data/formats-data.js +3 -3
  8. package/build/data/formats-data.js.map +1 -1
  9. package/build/data/items.js +5 -5
  10. package/build/data/items.js.map +1 -1
  11. package/build/data/learnsets.js +7 -6
  12. package/build/data/learnsets.js.map +1 -1
  13. package/build/data/mods/gen1/formats-data.js +1 -1
  14. package/build/data/mods/gen1/formats-data.js.map +1 -1
  15. package/build/data/mods/gen1/moves.js +1 -4
  16. package/build/data/mods/gen1/moves.js.map +1 -1
  17. package/build/data/mods/gen1/scripts.js +1 -1
  18. package/build/data/mods/gen1/scripts.js.map +1 -1
  19. package/build/data/mods/gen2/items.js +28 -0
  20. package/build/data/mods/gen2/items.js.map +1 -1
  21. package/build/data/mods/gen2/moves.js +2 -5
  22. package/build/data/mods/gen2/moves.js.map +1 -1
  23. package/build/data/mods/gen3/items.js +28 -0
  24. package/build/data/mods/gen3/items.js.map +1 -1
  25. package/build/data/mods/gen3/moves.js +0 -10
  26. package/build/data/mods/gen3/moves.js.map +1 -1
  27. package/build/data/mods/gen3/scripts.js +2 -2
  28. package/build/data/mods/gen3/scripts.js.map +1 -1
  29. package/build/data/mods/gen4/abilities.js +20 -0
  30. package/build/data/mods/gen4/abilities.js.map +1 -1
  31. package/build/data/mods/gen4/items.js +28 -0
  32. package/build/data/mods/gen4/items.js.map +1 -1
  33. package/build/data/mods/gen4/moves.js +17 -10
  34. package/build/data/mods/gen4/moves.js.map +1 -1
  35. package/build/data/mods/gen4/rulesets.js +2 -1
  36. package/build/data/mods/gen4/rulesets.js.map +1 -1
  37. package/build/data/mods/gen5/items.js +0 -4
  38. package/build/data/mods/gen5/items.js.map +1 -1
  39. package/build/data/mods/gen5/rulesets.js +2 -1
  40. package/build/data/mods/gen5/rulesets.js.map +1 -1
  41. package/build/data/mods/gen6/items.js +24 -0
  42. package/build/data/mods/gen6/items.js.map +1 -1
  43. package/build/data/mods/gen7/abilities.js +31 -0
  44. package/build/data/mods/gen7/abilities.js.map +1 -1
  45. package/build/data/mods/gen7/formats-data.js +4 -4
  46. package/build/data/mods/gen7/formats-data.js.map +1 -1
  47. package/build/data/mods/gen7/items.js +12 -0
  48. package/build/data/mods/gen7/items.js.map +1 -1
  49. package/build/data/mods/gen7/moves.js +14 -0
  50. package/build/data/mods/gen7/moves.js.map +1 -1
  51. package/build/data/mods/gen7/rulesets.js +2 -1
  52. package/build/data/mods/gen7/rulesets.js.map +1 -1
  53. package/build/data/moves.js +84 -91
  54. package/build/data/moves.js.map +1 -1
  55. package/build/data/pokedex.js +2 -2
  56. package/build/data/pokedex.js.map +1 -1
  57. package/build/data/rulesets.js +74 -4
  58. package/build/data/rulesets.js.map +1 -1
  59. package/build/data/tags.js +3 -3
  60. package/build/data/tags.js.map +1 -1
  61. package/build/data/text/items.js +1 -0
  62. package/build/data/text/items.js.map +1 -1
  63. package/build/data/text/moves.js +13 -11
  64. package/build/data/text/moves.js.map +1 -1
  65. package/build/sim/battle-actions.js +12 -4
  66. package/build/sim/battle-actions.js.map +1 -1
  67. package/build/sim/battle-queue.d.ts +2 -2
  68. package/build/sim/battle-queue.js +8 -0
  69. package/build/sim/battle-queue.js.map +1 -1
  70. package/build/sim/battle.js +85 -7
  71. package/build/sim/battle.js.map +1 -1
  72. package/build/sim/dex-conditions.d.ts +3 -2
  73. package/build/sim/dex-conditions.js.map +1 -1
  74. package/build/sim/dex-moves.d.ts +2 -1
  75. package/build/sim/dex-moves.js.map +1 -1
  76. package/build/sim/exported-global-types.d.ts +1 -0
  77. package/build/sim/global-types.d.ts +1 -0
  78. package/build/sim/pokemon.js +18 -5
  79. package/build/sim/pokemon.js.map +1 -1
  80. package/build/sim/team-validator.js +16 -5
  81. package/build/sim/team-validator.js.map +1 -1
  82. package/build/sim/tools/exhaustive-runner.d.ts +8 -0
  83. package/build/sim/tools/exhaustive-runner.js +18 -7
  84. package/build/sim/tools/exhaustive-runner.js.map +1 -1
  85. package/config/formats.ts +172 -179
  86. package/data/aliases.ts +2 -2
  87. package/data/conditions.ts +4 -1
  88. package/data/formats-data.ts +3 -3
  89. package/data/items.ts +5 -5
  90. package/data/learnsets.ts +7 -6
  91. package/data/mods/gen1/formats-data.ts +1 -1
  92. package/data/mods/gen1/moves.ts +1 -4
  93. package/data/mods/gen1/scripts.ts +1 -1
  94. package/data/mods/gen2/items.ts +28 -0
  95. package/data/mods/gen2/moves.ts +2 -5
  96. package/data/mods/gen3/items.ts +28 -0
  97. package/data/mods/gen3/moves.ts +0 -10
  98. package/data/mods/gen3/scripts.ts +3 -3
  99. package/data/mods/gen4/abilities.ts +20 -0
  100. package/data/mods/gen4/items.ts +28 -0
  101. package/data/mods/gen4/moves.ts +16 -11
  102. package/data/mods/gen4/rulesets.ts +2 -1
  103. package/data/mods/gen5/items.ts +0 -4
  104. package/data/mods/gen5/rulesets.ts +2 -1
  105. package/data/mods/gen6/items.ts +24 -0
  106. package/data/mods/gen7/abilities.ts +31 -0
  107. package/data/mods/gen7/formats-data.ts +4 -4
  108. package/data/mods/gen7/items.ts +12 -0
  109. package/data/mods/gen7/moves.ts +14 -0
  110. package/data/mods/gen7/rulesets.ts +2 -1
  111. package/data/moves.ts +84 -81
  112. package/data/pokedex.ts +2 -2
  113. package/data/rulesets.ts +73 -6
  114. package/data/tags.ts +3 -3
  115. package/data/text/items.ts +2 -0
  116. package/data/text/moves.ts +14 -11
  117. package/package.json +2 -2
  118. package/sim/battle-actions.ts +16 -5
  119. package/sim/battle-queue.ts +10 -2
  120. package/sim/battle.ts +81 -7
  121. package/sim/dex-conditions.ts +7 -2
  122. package/sim/dex-moves.ts +2 -1
  123. package/sim/exported-global-types.ts +3 -0
  124. package/sim/global-types.ts +3 -0
  125. package/sim/pokemon.ts +19 -7
  126. package/sim/team-validator.ts +17 -5
  127. 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(ExhaustiveRunner.onlyValid(dex.gen, dex.data.Pokedex, p => dex.species.get(p),
114
- (_, p) => (p.name !== 'Pichu-Spiky-eared' && p.name.substr(0, 8) !== 'Pikachu-')), this.prng),
115
- items: new Pool(ExhaustiveRunner.onlyValid(dex.gen, dex.data.Items, i => dex.items.get(i)), this.prng),
116
- abilities: new Pool(ExhaustiveRunner.onlyValid(dex.gen, dex.data.Abilities, a => dex.abilities.get(a)), this.prng),
117
- moves: new Pool(ExhaustiveRunner.onlyValid(dex.gen, dex.data.Moves, m => dex.moves.get(m),
118
- m => (m !== 'struggle' && (m === 'hiddenpower' || m.substr(0, 11) !== 'hiddenpower'))), this.prng),
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}[]> {