@pkmn/engine 0.1.0-dev.6195e056 → 0.1.0-dev.6e63f5e4
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/README.md +101 -62
- package/build/pkg/addon.d.ts +7 -0
- package/build/pkg/addon.js +112 -0
- package/build/pkg/addon.js.map +1 -0
- package/build/pkg/data/layout.json +25 -3
- package/build/pkg/data/protocol.json +22 -4
- package/build/pkg/data.d.ts +1 -2
- package/build/pkg/data.js +3 -5
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/gen1.d.ts +5 -4
- package/build/pkg/gen1.js +47 -31
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +16 -13
- package/build/pkg/index.js +1 -1
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +4 -2
- package/build/pkg/protocol.js +5 -3
- package/build/pkg/protocol.js.map +1 -1
- package/build/test/display.js +400 -0
- package/build/test/display.js.map +1 -0
- package/build/tools/debug.js +133 -0
- package/build/tools/debug.js.map +1 -0
- package/build.zig +104 -90
- package/package.json +57 -36
- package/src/bin/install-pkmn-engine +68 -36
- package/src/bin/pkmn-debug +62 -0
- package/src/lib/binding/node.zig +47 -142
- package/src/lib/binding/wasm.zig +6 -4
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +15 -27
- package/src/lib/common/debug.zig +74 -0
- package/src/lib/common/js.zig +118 -0
- package/src/lib/common/optional.zig +60 -0
- package/src/lib/common/options.zig +12 -3
- package/src/lib/common/protocol.zig +416 -198
- package/src/lib/common/rational.zig +353 -0
- package/src/lib/common/rng.zig +15 -15
- package/src/lib/common/util.zig +12 -0
- package/src/lib/gen1/README.md +282 -165
- package/src/lib/gen1/calc.zig +426 -0
- package/src/lib/gen1/chance.zig +1058 -0
- package/src/lib/gen1/data/moves.zig +178 -180
- package/src/lib/gen1/data/species.zig +2 -2
- package/src/lib/gen1/data/types.zig +4 -4
- package/src/lib/gen1/data.zig +79 -65
- package/src/lib/gen1/helpers.zig +592 -36
- package/src/lib/gen1/mechanics.zig +1097 -662
- package/src/lib/gen2/README.md +87 -13
- package/src/lib/gen2/data/items.zig +3 -3
- package/src/lib/gen2/data/moves.zig +635 -563
- package/src/lib/gen2/data/species.zig +1 -1
- package/src/lib/gen2/data/types.zig +4 -4
- package/src/lib/gen2/data.zig +109 -77
- package/src/lib/gen2/helpers.zig +16 -22
- package/src/lib/gen2/mechanics.zig +1160 -11
- package/src/lib/pkmn.zig +68 -9
- package/src/test/display/pkmn.html.tmpl +368 -0
package/README.md
CHANGED
|
@@ -12,17 +12,25 @@
|
|
|
12
12
|
<img alt="License" src="https://img.shields.io/badge/License-MIT-blue.svg" />
|
|
13
13
|
</a>
|
|
14
14
|
</p>
|
|
15
|
+
|
|
16
|
+
> [!WARNING]
|
|
17
|
+
> **This project is under heavy development** and currently the `main` branch contains numerous breaking
|
|
18
|
+
> changes which may not work and which are not fully documented. Please **wait for the forthcoming
|
|
19
|
+
> initial v0.1 release** before depending on this project (code from the
|
|
20
|
+
> [`old`](https://github.com/pkmn/engine/releases/tag/old) tag can also be used to experiment with a
|
|
21
|
+
> more stable version of the codebase).
|
|
22
|
+
|
|
15
23
|
<hr />
|
|
16
24
|
|
|
17
25
|
A minimal, complete, Pokémon battle simulation engine optimized for performance and
|
|
18
26
|
[designed](docs/DESIGN.md) for tooling, embedded systems, and [artificial
|
|
19
27
|
intelligence](https://github.com/pkmn/0-ERROR) use cases. This engine aims to be a frame-accurate and
|
|
20
28
|
[bug-for-bug compatible](http://www.catb.org/jargon/html/B/bug-for-bug-compatible.html)
|
|
21
|
-
implementation of both Pokémon battles as defined by the original game code
|
|
29
|
+
implementation of both Pokémon battles as defined by the original game code and the [Pokémon
|
|
22
30
|
Showdown](https://pokemonshowdown.com/)[^1] simulator which represents Pokémon battling as practically
|
|
23
31
|
interpreted online.
|
|
24
32
|
|
|
25
|
-
The pkmn engine is
|
|
33
|
+
The pkmn engine is [**more than 1000× faster**](docs/TESTING.md#results) than the
|
|
26
34
|
[patched](docs/TESTING.md#patches) [Pokémon Showdown simulator
|
|
27
35
|
code](https://github.com/smogon/pokemon-showdown) when playing out supported formats in
|
|
28
36
|
compatibility mode and is extensively [tested](docs/TESTING.md) and [documented](docs). Note,
|
|
@@ -49,14 +57,14 @@ $ zig build --prefix /usr/local -Doptimize=ReleaseFast
|
|
|
49
57
|
```
|
|
50
58
|
|
|
51
59
|
The Zig website has [installation instructions](https://ziglang.org/learn/getting-started/) which
|
|
52
|
-
walk through how to install Zig on each platform - the engine code should work on Zig v0.11.0
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
walk through how to install Zig on each platform - the engine code should work on Zig v0.11.0 or
|
|
61
|
+
greater, though tracks Zig's master branch so this may change in the future if breaking language
|
|
62
|
+
changes are introduced.
|
|
55
63
|
|
|
56
64
|
`libpkmn` can be built with `-Dshowdown` to instead produce the Pokémon Showdown compatible
|
|
57
|
-
`libpkmn-showdown` library. Furthermore,
|
|
58
|
-
`libpkmn` and `libpkmn-showdown` objects available in the binary release are compiled with
|
|
59
|
-
|
|
65
|
+
`libpkmn-showdown` library. Furthermore, protocol message logging can be enabled through `-Dlog`.
|
|
66
|
+
The `libpkmn` and `libpkmn-showdown` objects available in the binary release are both compiled with
|
|
67
|
+
the `-Dlog` flag by default.
|
|
60
68
|
|
|
61
69
|
### `@pkmn/engine`
|
|
62
70
|
|
|
@@ -67,14 +75,14 @@ $ npm install @pkmn/engine
|
|
|
67
75
|
```
|
|
68
76
|
|
|
69
77
|
The driver depends on being able to find compiled Node/WASM addons in
|
|
70
|
-
`node_modules/@pkmn/engine/build/lib`
|
|
71
|
-
|
|
72
|
-
[`install-pkmn-engine`](src/bin/install-pkmn-engine) which
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
**If you have configured
|
|
78
|
+
`node_modules/@pkmn/engine/build/lib` to be useful. When you install the package a [`postinstall`
|
|
79
|
+
lifecycle script](https://docs.npmjs.com/cli/v8/using-npm/scripts) runs
|
|
80
|
+
[`install-pkmn-engine`](src/bin/install-pkmn-engine) which checks for a compatible `zig` compiler
|
|
81
|
+
(see earlier regarding minimum version) and download one to `node_module/@pkmn/engine/build/bin` if
|
|
82
|
+
it can't find one, as well as looking for (and downloading, if necessary) the required Node headers
|
|
83
|
+
needed to successfully build the addons natively.
|
|
84
|
+
|
|
85
|
+
**If you have configured `npm` to `--ignore-scripts` you must either run `npx install-pkmn-engine`
|
|
78
86
|
directly or build the addons manually and place the artifacts in the expected paths.**
|
|
79
87
|
|
|
80
88
|
### `pkmn`
|
|
@@ -88,23 +96,23 @@ adding the following to your `build.zig`:
|
|
|
88
96
|
const std = @import("std");
|
|
89
97
|
const pkmn = @import("lib/pkmn/build.zig");
|
|
90
98
|
|
|
91
|
-
pub fn build(b: *std.
|
|
99
|
+
pub fn build(b: *std.Build) void {
|
|
92
100
|
...
|
|
93
|
-
exe.addModule("pkmn", pkmn.module(b, .{ .showdown = true, .
|
|
101
|
+
exe.addModule("pkmn", pkmn.module(b, .{ .showdown = true, .log = true }));
|
|
94
102
|
...
|
|
95
103
|
}
|
|
96
104
|
```
|
|
97
105
|
|
|
98
106
|
The engine's `build.zig` exposes a `module` function that takes an options structure to allow for
|
|
99
|
-
configuring whether or not Pokémon Showdown compatibility mode or
|
|
100
|
-
Alternatively, you may set options via a `pkmn_options` [root source file
|
|
107
|
+
configuring whether or not Pokémon Showdown compatibility mode or protocol message logging should be
|
|
108
|
+
enabled. Alternatively, you may set options via a `pkmn_options` [root source file
|
|
101
109
|
declaration](https://ziglang.org/documentation/master/#Root-Source-File). There are several
|
|
102
110
|
undocumented internal options that can be tweaked as well via build or root options, though these
|
|
103
|
-
options
|
|
111
|
+
options aren't officially supported, affect correctness, and may change meaning or behavior without
|
|
104
112
|
warning. Use at your own risk.
|
|
105
113
|
|
|
106
114
|
```zig
|
|
107
|
-
pub const pkmn_options = .{ .showdown = true, .
|
|
115
|
+
pub const pkmn_options = .{ .showdown = true, .log = true };
|
|
108
116
|
```
|
|
109
117
|
|
|
110
118
|
## Usage
|
|
@@ -112,23 +120,23 @@ pub const pkmn_options = .{ .showdown = true, .trace = true };
|
|
|
112
120
|
For each Pokémon generation, the engine provides a battle structure with two functions - a function
|
|
113
121
|
to `update` the battle's state based on both players' choices and a function that defines which
|
|
114
122
|
`choices` are valid at that decision point (at the beginning of a battle both player's must "pass"
|
|
115
|
-
as their first choice
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
as their first choice to switch in the first member of their party). If `-Dlog` protocol logging is
|
|
124
|
+
enabled each update produces logs which can be decoded into a buffer (`LOGS_SIZE` constants are
|
|
125
|
+
provided to make it easy to allocate a buffer of the correct size). Each `update` returns a result
|
|
126
|
+
to indicate either that the battle has terminated or which types of choices are available for each
|
|
127
|
+
player.
|
|
120
128
|
|
|
121
129
|
Unlike [Pokémon Showdown's
|
|
122
130
|
SIM-PROTOCOL](https://github.com/smogon/pokemon-showdown/blob/master/sim/SIM-PROTOCOL.md#choice-requests)
|
|
123
131
|
which provides a rich request object at each decision point, the pkmn engine computes the possible
|
|
124
|
-
choices on demand based on the result of the previous `update` and the battle state (`
|
|
132
|
+
choices on demand based on the result of the previous `update` and the battle state (`CHOICES_SIZE`
|
|
125
133
|
is a good size to initialize the buffer passed to `choices`). **Attempting to update the battle with
|
|
126
134
|
a choice not present in the options returned by `choices` is undefined behavior and may corrupt
|
|
127
135
|
state or cause the engine to crash.**
|
|
128
136
|
|
|
129
137
|
Battles may be played out from any point but to freshly initialize a battle which is yet to start
|
|
130
138
|
the turn count and active Pokémon should be zeroed out (driver code should handle this for you).
|
|
131
|
-
Most driver code should also provide helpers to make
|
|
139
|
+
Most driver code should also provide helpers to make initializing battle convenient - check the
|
|
132
140
|
respective documentation and examples for the bindings being used. The engine's [protocol
|
|
133
141
|
documentation](docs/PROTOCOL.md) goes into greater detail on the specifics of updates and the
|
|
134
142
|
potential logs that may result.
|
|
@@ -139,36 +147,39 @@ potential logs that may result.
|
|
|
139
147
|
### C
|
|
140
148
|
|
|
141
149
|
[`pkmn.h`](src/include/pkmn.h) exports the C API for `libpkmn`. Symbols are all prefixed with
|
|
142
|
-
`pkmn_` to avoid name collisions. If `-
|
|
143
|
-
|
|
150
|
+
`pkmn_` to avoid name collisions. If `-Dlog` is enabled and logging throws an error then the error
|
|
151
|
+
is encoded in the `pkmn_result` and can be checked with `pkmn_error`.
|
|
144
152
|
|
|
145
153
|
```c
|
|
146
154
|
#include <pkmn.h>
|
|
147
155
|
|
|
156
|
+
pkmn_battle_options options;
|
|
157
|
+
pkmn_gen1_battle_options_set(&options, ...);
|
|
148
158
|
pkmn_battle battle = ...;
|
|
149
|
-
|
|
159
|
+
|
|
150
160
|
pkmn_result result;
|
|
151
161
|
pkmn_choice c1 = 0, c2 = 0;
|
|
152
|
-
while (!pkmn_result_type(result = pkmn_battle_update(&battle, c1, c2,
|
|
162
|
+
while (!pkmn_result_type(result = pkmn_battle_update(&battle, c1, c2, &options))) {
|
|
153
163
|
c1 = choose(PKMN_PLAYER_P1, pkmn_result_p1(result));
|
|
154
164
|
c2 = choose(PKMN_PLAYER_P2, pkmn_result_p2(result));
|
|
165
|
+
pkmn_gen1_battle_options_set(&options, ...);
|
|
155
166
|
}
|
|
156
167
|
if (pkmn_error(result)) exit(1);
|
|
157
168
|
```
|
|
158
169
|
|
|
159
170
|
[(full code)](src/examples/c/example.c)
|
|
160
171
|
|
|
161
|
-
The C API
|
|
172
|
+
The C API doesn't export any helpers for creating or accessing the opaque battle objects - it's
|
|
162
173
|
instead intended to be used as the foundation for more ergonomic bindings in [other
|
|
163
174
|
languages](#other) (the lack of namespaces and bit fields having an implementation-defined layout in
|
|
164
175
|
C are the main contributing factors to the sparseness of what `libpkmn` chooses to expose).
|
|
165
176
|
|
|
166
177
|
### JavaScript / TypeScript
|
|
167
178
|
|
|
168
|
-
`@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) which
|
|
179
|
+
`@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) package which
|
|
169
180
|
requires a `Dex` implementation to be provided as well. The `Battle.create` function can be used to
|
|
170
181
|
initialize a `Battle` from the beginning, or `Battle.restore` can be used to re-instantiate a battle
|
|
171
|
-
which is in
|
|
182
|
+
which is already in progress. If logging is enabled the output can be turned into Pokémon Showdown
|
|
172
183
|
protocol via `Log.parse`.
|
|
173
184
|
|
|
174
185
|
```ts
|
|
@@ -193,18 +204,18 @@ console.log(result);
|
|
|
193
204
|
|
|
194
205
|
[(full code)](src/examples/js/example.ts)
|
|
195
206
|
|
|
196
|
-
By default, the `@pkmn/engine` package
|
|
207
|
+
By default, the `@pkmn/engine` package compiles the engine with `-Dshowdown`, though by running
|
|
197
208
|
`install-pkmn-engine` directly and passing in `--options` you can override this default and build
|
|
198
209
|
different configurations of the extension for the driver to use. The driver can support
|
|
199
210
|
configurations both with and without Pokémon Showdown compatibility simultaneously if present. On
|
|
200
|
-
update, the post-install script
|
|
211
|
+
update, the post-install script attempts to rebuild whichever extensions it finds with the same
|
|
201
212
|
configuration parameters that were originally used meaning updating to the newest version of the
|
|
202
213
|
library should be seamless.
|
|
203
214
|
|
|
204
215
|
Despite relying on the native engine code, the `@pkmn/engine` code is designed to also work in
|
|
205
216
|
browsers which support [WebAssembly](https://webassembly.org/). Running `npm run start:web` from the
|
|
206
|
-
[`examples`](src/examples/js) directory
|
|
207
|
-
|
|
217
|
+
[`examples`](src/examples/js) directory starts a server that can be used to demonstrate the engine
|
|
218
|
+
running in the browser.
|
|
208
219
|
|
|
209
220
|
### Zig
|
|
210
221
|
|
|
@@ -216,18 +227,18 @@ const std = @import("std");
|
|
|
216
227
|
const pkmn = @import("pkmn");
|
|
217
228
|
|
|
218
229
|
var random = std.rand.DefaultPrng.init(seed).random();
|
|
219
|
-
var
|
|
230
|
+
var choices: [pkmn.CHOICES_SIZE]pkmn.Choice = undefined;
|
|
220
231
|
|
|
221
232
|
var battle = ...
|
|
222
|
-
var
|
|
233
|
+
var options = pkmn.battle.options(...);
|
|
223
234
|
|
|
224
235
|
var c1 = pkmn.Choice{};
|
|
225
236
|
var c2 = pkmn.Choice{};
|
|
226
237
|
|
|
227
|
-
var result = try battle.update(c1, c2,
|
|
228
|
-
while (result.type == .None) : (result = try battle.update(c1, c2,
|
|
229
|
-
c1 =
|
|
230
|
-
c2 =
|
|
238
|
+
var result = try battle.update(c1, c2, &options);
|
|
239
|
+
while (result.type == .None) : (result = try battle.update(c1, c2, &options)) {
|
|
240
|
+
c1 = choices[random.uintLessThan(u8, battle.choices(.P1, result.p1, &choices))];
|
|
241
|
+
c2 = choices[random.uintLessThan(u8, battle.choices(.P2, result.p2, &choices))];
|
|
231
242
|
}
|
|
232
243
|
|
|
233
244
|
std.debug.print("{}\n", .{result.type});
|
|
@@ -237,7 +248,7 @@ std.debug.print("{}\n", .{result.type});
|
|
|
237
248
|
|
|
238
249
|
The Zig package also supports some APIs which are difficult to expose elsewhere such as the
|
|
239
250
|
`FixedRNG` which allows you to fully specify the exact RNG frames (which can be useful for ensuring
|
|
240
|
-
certain outcomes/effects always occur) for a battle, though doing so
|
|
251
|
+
certain outcomes/effects always occur) for a battle, though doing so changes the size of the
|
|
241
252
|
`Battle` object.
|
|
242
253
|
|
|
243
254
|
### Other
|
|
@@ -248,12 +259,40 @@ simplify the process even further [`src/data`](src/data) contains JSON dumps of
|
|
|
248
259
|
data, structure sizes and offsets, and protocol information used by the reference driver code. The
|
|
249
260
|
following is a list of known `libpkmn` bindings written by developers outside of the [pkmn
|
|
250
261
|
organization](https://github.com/pkmn) that may be helpful (though note that these projects may not
|
|
251
|
-
necessarily be up-to-date/complete/correct - inclusion in this list
|
|
262
|
+
necessarily be up-to-date/complete/correct - inclusion in this list doesn't imply endorsement):
|
|
263
|
+
|
|
264
|
+
| Language | License | URL |
|
|
265
|
+
| ---------- | --------- | ------------------------------------ |
|
|
266
|
+
| **C++** | `BSL-1.0` | https://github.com/pasyg/wrapsire |
|
|
267
|
+
| **Python** | `MIT` | https://github.com/AnnikaCodes/PyKMN |
|
|
268
|
+
|
|
252
269
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
270
|
+
#### `pkmn-debug`
|
|
271
|
+
|
|
272
|
+
The [`@pkmn/engine`](#pkmnengine) package ships with a `pkmn-debug` tool which exists to decode the
|
|
273
|
+
binary data structures and protocols used by the engine and to output a [standalone
|
|
274
|
+
webpage](https://pkmn.cc/debug.html) that can be used for debugging. To use this tool in a folder
|
|
275
|
+
that has the `@pkmn/engine` package installed locally you can use `npx pkmn-debug`, though you may
|
|
276
|
+
also wish to install the package globally to be able to use this tool anywhere without
|
|
277
|
+
[`npx`](https://docs.npmjs.com/cli/v7/commands/npx):
|
|
278
|
+
|
|
279
|
+
```sh
|
|
280
|
+
$ npm install --global @pkmn/engine
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
By default, `pkmn-debug` expects to read [binary debug protocol](docs/PROTOCOL.md#debugging) from
|
|
284
|
+
[standard input](https://en.wikipedia.org/wiki/Standard_streams) and output HTML to standard output:
|
|
285
|
+
|
|
286
|
+
```sh
|
|
287
|
+
$ <cmd> | pkmn-debug > index.html
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Alternatively, if a single filename argument is passed to the `pkmn-debug` it reads from that
|
|
291
|
+
instead:
|
|
292
|
+
|
|
293
|
+
```sh
|
|
294
|
+
$ pkmn-debug <file> > index.html
|
|
295
|
+
```
|
|
257
296
|
|
|
258
297
|
## Status
|
|
259
298
|
|
|
@@ -270,14 +309,14 @@ Currently, most of the foundational work from stage 0 is done:
|
|
|
270
309
|
|
|
271
310
|
- [benchmark and integration testing](src/test) infrastructure
|
|
272
311
|
- [documentation](docs) about design, research, methodology, etc
|
|
273
|
-
- definition and implementation of the [protocol](docs/PROTOCOL.md) that
|
|
312
|
+
- definition and implementation of the [protocol](docs/PROTOCOL.md) that's used by the engine
|
|
274
313
|
|
|
275
|
-
**Stage 1 is currently in progress** and
|
|
314
|
+
**Stage 1 is currently in progress** and involves the implementation of the actual Generation I & II
|
|
276
315
|
battle engines, followed by Generation III & IV in stage 2. The implementation of further Pokémon
|
|
277
|
-
generations is in scope for the project but
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
316
|
+
generations is in scope for the project but shouldn't be considered part of the immediate roadmap
|
|
317
|
+
(i.e. exploring the options for broadening support for old generation APIs is given higher priority
|
|
318
|
+
than implementing more modern generations). Furthermore, implementation of modern generations is
|
|
319
|
+
soft-blocked on the [availability of high quality
|
|
281
320
|
decompilations](https://github.com/orgs/pret/repositories) of the original games in question.
|
|
282
321
|
|
|
283
322
|
Certain features will always be deemed **out of scope**:
|
|
@@ -295,10 +334,10 @@ The pkmn engine is distributed under the terms of the [MIT License](LICENSE).
|
|
|
295
334
|
[^1]: In the case of Pokémon Showdown, only bugs which stem from a misimplementation of specific
|
|
296
335
|
effects are reproduced in the engine, bugs which are the result of a misunderstanding of the
|
|
297
336
|
fundamental mechanics of Pokémon or which simply arise due to specific Pokémon Showdown
|
|
298
|
-
implementation details that
|
|
299
|
-
choices
|
|
337
|
+
implementation details that aren't replicable without making the same (incorrect) architectural
|
|
338
|
+
choices aren't. Furthermore, the "Pokémon Showdown" code referenced by this project includes
|
|
300
339
|
several [patches](docs/TESTING.md#patches) to improve accuracy and smooth over some of the more
|
|
301
340
|
egregious implementation issues. In practical terms, the vast majority of games played out in the
|
|
302
|
-
pkmn engine's compatibility mode and on this patched Pokémon Showdown simulator
|
|
303
|
-
it
|
|
341
|
+
pkmn engine's compatibility mode and on this patched Pokémon Showdown simulator are the same,
|
|
342
|
+
it's only in a well defined and documented set of circumstances where the two implementations
|
|
304
343
|
diverge.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Choice, Player, Result } from '.';
|
|
2
|
+
export declare function check(showdown: boolean): void;
|
|
3
|
+
export declare function supports(showdown: boolean, log?: boolean): boolean;
|
|
4
|
+
export declare function update(index: number, showdown: boolean, battle: ArrayBuffer, c1?: Choice, c2?: Choice, log?: ArrayBuffer): Result;
|
|
5
|
+
export declare function choices(index: number, showdown: boolean, battle: ArrayBuffer, player: Player, choice: Choice['type'], buf: ArrayBuffer): Choice[];
|
|
6
|
+
export declare function choose(index: number, showdown: boolean, battle: ArrayBuffer, player: Player, choice: Choice['type'], buf: ArrayBuffer, fn: (n: number) => number): Choice;
|
|
7
|
+
export declare function size(index: number, type: 'choices' | 'log'): number;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.size = exports.choose = exports.choices = exports.update = exports.supports = exports.check = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const _1 = require(".");
|
|
29
|
+
const ROOT = path.join(__dirname, '..', '..');
|
|
30
|
+
let ADDON = undefined;
|
|
31
|
+
function load() {
|
|
32
|
+
if (ADDON)
|
|
33
|
+
return ADDON;
|
|
34
|
+
let pkmn = undefined;
|
|
35
|
+
let showdown = undefined;
|
|
36
|
+
try {
|
|
37
|
+
pkmn = require(path.join(ROOT, 'build', 'lib', 'pkmn.node')).engine;
|
|
38
|
+
}
|
|
39
|
+
catch { }
|
|
40
|
+
try {
|
|
41
|
+
showdown =
|
|
42
|
+
require(path.join(ROOT, 'build', 'lib', 'pkmn-showdown.node')).engine;
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
if (!pkmn && !showdown) {
|
|
46
|
+
throw new Error('Could not find native addons - did you run `npx install-pkmn-engine`?');
|
|
47
|
+
}
|
|
48
|
+
return (ADDON = [pkmn, showdown]);
|
|
49
|
+
}
|
|
50
|
+
function check(showdown) {
|
|
51
|
+
if (!load()[+showdown]) {
|
|
52
|
+
const opts = ADDON[+!showdown].options.log ? ['-log'] : [];
|
|
53
|
+
if (showdown)
|
|
54
|
+
opts.push('-Dshowdown');
|
|
55
|
+
throw new Error(`@pkmn/engine has ${showdown ? 'not' : 'only'} been configured to support Pokémon Showdown.` +
|
|
56
|
+
`\n(running \`npx install-pkmn-engine --options='${opts.join(' ')}'\` can fix this issue).`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.check = check;
|
|
60
|
+
function supports(showdown, log) {
|
|
61
|
+
if (!load()[+showdown])
|
|
62
|
+
return false;
|
|
63
|
+
if (log === undefined)
|
|
64
|
+
return true;
|
|
65
|
+
return ADDON[+showdown].options.log === log;
|
|
66
|
+
}
|
|
67
|
+
exports.supports = supports;
|
|
68
|
+
function update(index, showdown, battle, c1, c2, log) {
|
|
69
|
+
return _1.Result.decode(ADDON[+showdown].bindings[index]
|
|
70
|
+
.update(battle, _1.Choice.encode(c1), _1.Choice.encode(c2), log));
|
|
71
|
+
}
|
|
72
|
+
exports.update = update;
|
|
73
|
+
function choices(index, showdown, battle, player, choice, buf) {
|
|
74
|
+
const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
|
|
75
|
+
const n = ADDON[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
|
|
76
|
+
// The top-level API signature means our hands our tied with respect to
|
|
77
|
+
// writing really fast bindings here. The simplest approach would be to return
|
|
78
|
+
// the ArrayBuffer the bindings populate as well as its size and only decode a
|
|
79
|
+
// Choice after the selection. However, given that we need to return
|
|
80
|
+
// `Choices[]` we need to decode all of them even if they're not all being
|
|
81
|
+
// used which is wasteful. This shouldn't be *that* bad as its a very small
|
|
82
|
+
// list, but its still wasted work. Switching the top-level API to return an
|
|
83
|
+
// Iterable<Choice> doesn't help as we need both the length and the ability to
|
|
84
|
+
// randomly access it, so the best way to make the current API fast would be
|
|
85
|
+
// to have the Zig bindings create Choice objects directly, only that won't
|
|
86
|
+
// scale well as it would require us to basically rewrite the low-level
|
|
87
|
+
// choices function for each generation within node.zig. We could do something
|
|
88
|
+
// really galaxy-brained and return some sort of frankenstein subclass of
|
|
89
|
+
// Array backed by ArrayBuffer which would lazily decode the Choice on access,
|
|
90
|
+
// but thats ultimately not worth the effort. You can't have both a high-level
|
|
91
|
+
// idiomatic API and performance here, hence why the choose function below
|
|
92
|
+
// exists.
|
|
93
|
+
const options = new Array(n);
|
|
94
|
+
const data = new Uint8Array(buf);
|
|
95
|
+
for (let i = 0; i < n; i++)
|
|
96
|
+
options[i] = _1.Choice.decode(data[i]);
|
|
97
|
+
return options;
|
|
98
|
+
}
|
|
99
|
+
exports.choices = choices;
|
|
100
|
+
function choose(index, showdown, battle, player, choice, buf, fn) {
|
|
101
|
+
const request = choice[0] === 'p' ? 0 : choice[0] === 'm' ? 1 : 2;
|
|
102
|
+
const n = ADDON[+showdown].bindings[index].choices(battle, +(player !== 'p1'), request, buf);
|
|
103
|
+
const data = new Uint8Array(buf);
|
|
104
|
+
return _1.Choice.decode(data[fn(n)]);
|
|
105
|
+
}
|
|
106
|
+
exports.choose = choose;
|
|
107
|
+
function size(index, type) {
|
|
108
|
+
const bindings = (ADDON[1] ?? ADDON[0]).bindings[index];
|
|
109
|
+
return type[0] === 'c' ? bindings.CHOICES_SIZE : bindings.LOGS_SIZE;
|
|
110
|
+
}
|
|
111
|
+
exports.size = size;
|
|
112
|
+
//# sourceMappingURL=addon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/pkg/addon.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,wBAAyC;AAEzC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAE9C,IAAI,KAAK,GAAoD,SAAS,CAAC;AAcvE,SAAS,IAAI;IACX,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACxB,IAAI,IAAI,GAAgC,SAAS,CAAC;IAClD,IAAI,QAAQ,GAA+B,SAAS,CAAC;IACrD,IAAI;QACF,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,MAAyB,CAAC;KACxF;IAAC,MAAM,GAAG;IACX,IAAI;QACF,QAAQ;YACN,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,MAAwB,CAAC;KAC3F;IAAC,MAAM,GAAG;IACX,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;KAC1F;IACD,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,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CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,MAAM,CAAC,GAAG,KAAM,CAAC,CAAC,QAAQ,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAC/F,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,SAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAbD,wBAaC;AAED,SAAgB,IAAI,CAAC,KAAa,EAAE,IAAuB;IACzD,MAAM,QAAQ,GAAG,CAAC,KAAM,CAAC,CAAC,CAAC,IAAI,KAAM,CAAC,CAAC,CAAC,CAAE,CAAC,QAAQ,CAAC,KAAK,CAAE,CAAC;IAC5D,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC;AACtE,CAAC;AAHD,oBAGC"}
|
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
"Battle": 384,
|
|
5
5
|
"Side": 184,
|
|
6
6
|
"Pokemon": 24,
|
|
7
|
-
"ActivePokemon": 32
|
|
7
|
+
"ActivePokemon": 32,
|
|
8
|
+
"Actions": 16,
|
|
9
|
+
"Summaries": 12
|
|
8
10
|
},
|
|
9
11
|
"offsets": {
|
|
10
12
|
"Battle": {
|
|
11
13
|
"sides": 0,
|
|
12
14
|
"turn": 368,
|
|
13
15
|
"last_damage": 370,
|
|
14
|
-
"
|
|
15
|
-
"rng":
|
|
16
|
+
"last_moves": 372,
|
|
17
|
+
"rng": 374
|
|
16
18
|
},
|
|
17
19
|
"Side": {
|
|
18
20
|
"pokemon": 0,
|
|
@@ -80,6 +82,26 @@
|
|
|
80
82
|
"disabled_duration": 52,
|
|
81
83
|
"disabled_move": 56,
|
|
82
84
|
"toxic": 59
|
|
85
|
+
},
|
|
86
|
+
"Action": {
|
|
87
|
+
"damage": 0,
|
|
88
|
+
"hit": 8,
|
|
89
|
+
"critical_hit": 10,
|
|
90
|
+
"secondary_chance": 12,
|
|
91
|
+
"speed_tie": 14,
|
|
92
|
+
"confused": 16,
|
|
93
|
+
"paralyzed": 18,
|
|
94
|
+
"duration": 20,
|
|
95
|
+
"durations": 24,
|
|
96
|
+
"move_slot": 40,
|
|
97
|
+
"multi_hit": 44,
|
|
98
|
+
"psywave": 48,
|
|
99
|
+
"metronome": 56
|
|
100
|
+
},
|
|
101
|
+
"Damage": {
|
|
102
|
+
"base": 0,
|
|
103
|
+
"final": 2,
|
|
104
|
+
"capped": 4
|
|
83
105
|
}
|
|
84
106
|
}
|
|
85
107
|
}
|
|
@@ -70,7 +70,8 @@
|
|
|
70
70
|
"Burst",
|
|
71
71
|
"ClearPositiveBoost",
|
|
72
72
|
"CanDynamax",
|
|
73
|
-
"SwapSideConditions"
|
|
73
|
+
"SwapSideConditions",
|
|
74
|
+
"Terastallize"
|
|
74
75
|
],
|
|
75
76
|
"Move": [
|
|
76
77
|
"None",
|
|
@@ -89,7 +90,8 @@
|
|
|
89
90
|
"Heal": [
|
|
90
91
|
"None",
|
|
91
92
|
"Silent",
|
|
92
|
-
"Drain"
|
|
93
|
+
"Drain",
|
|
94
|
+
"Leftovers"
|
|
93
95
|
],
|
|
94
96
|
"Damage": [
|
|
95
97
|
"None",
|
|
@@ -97,7 +99,8 @@
|
|
|
97
99
|
"Burn",
|
|
98
100
|
"Confusion",
|
|
99
101
|
"LeechSeed",
|
|
100
|
-
"RecoilOf"
|
|
102
|
+
"RecoilOf",
|
|
103
|
+
"Spikes"
|
|
101
104
|
],
|
|
102
105
|
"Status": [
|
|
103
106
|
"None",
|
|
@@ -136,7 +139,8 @@
|
|
|
136
139
|
"Mist",
|
|
137
140
|
"Struggle",
|
|
138
141
|
"Substitute",
|
|
139
|
-
"Splash"
|
|
142
|
+
"Splash",
|
|
143
|
+
"Attract"
|
|
140
144
|
],
|
|
141
145
|
"Start": [
|
|
142
146
|
"Bide",
|
|
@@ -157,6 +161,8 @@
|
|
|
157
161
|
"Confusion",
|
|
158
162
|
"Bide",
|
|
159
163
|
"Substitute",
|
|
164
|
+
"FutureSight",
|
|
165
|
+
"Encore",
|
|
160
166
|
"DisableSilent",
|
|
161
167
|
"ConfusionSilent",
|
|
162
168
|
"Mist",
|
|
@@ -169,5 +175,17 @@
|
|
|
169
175
|
"Immune": [
|
|
170
176
|
"None",
|
|
171
177
|
"OHKO"
|
|
178
|
+
],
|
|
179
|
+
"SideStart": [
|
|
180
|
+
"Safeguard",
|
|
181
|
+
"Reflect",
|
|
182
|
+
"LightScreen",
|
|
183
|
+
"Spikes"
|
|
184
|
+
],
|
|
185
|
+
"SideEnd": [
|
|
186
|
+
"Safeguard",
|
|
187
|
+
"Reflect",
|
|
188
|
+
"LightScreen",
|
|
189
|
+
"Spikes"
|
|
172
190
|
]
|
|
173
191
|
}
|
package/build/pkg/data.d.ts
CHANGED
|
@@ -26,8 +26,7 @@ export declare const LAYOUT: {
|
|
|
26
26
|
};
|
|
27
27
|
}[];
|
|
28
28
|
export declare const Data: {
|
|
29
|
-
|
|
30
|
-
view(data: number[]): DataView;
|
|
29
|
+
view(buf: number[] | Buffer): DataView;
|
|
31
30
|
};
|
|
32
31
|
/**
|
|
33
32
|
* Translation table for encoding/decoding Pokémon Showdown string identifiers
|
package/build/pkg/data.js
CHANGED
|
@@ -27,11 +27,9 @@ for (const gen of exports.LAYOUT) {
|
|
|
27
27
|
gen.offsets.Battle.p2 = gen.offsets.Battle.sides + gen.sizes.Side;
|
|
28
28
|
}
|
|
29
29
|
exports.Data = new class {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
view(data) {
|
|
34
|
-
return new DataView(this.buffer(data).buffer);
|
|
30
|
+
view(buf) {
|
|
31
|
+
buf = Array.isArray(buf) ? Buffer.from(buf) : buf;
|
|
32
|
+
return new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
35
33
|
}
|
|
36
34
|
};
|
|
37
35
|
const LOOKUPS = [];
|
package/build/pkg/data.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.js","sourceRoot":"","sources":["../../src/pkg/data.ts"],"names":[],"mappings":";;;;;;AAEA,+DAAsC;AACtC,qEAA6C;AAC7C,yEAAgD;AAEnC,QAAA,EAAE,GAAG,CAAC,GAAG,EAAE;IACtB,MAAM,EAAE,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IAC7B,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC,EAAE,CAAC;AAOQ,QAAA,GAAG,GAAG,kBAAc,CAAC;AAErB,QAAA,QAAQ,GAA+C,EAAE,CAAC;AACvE,KAAK,MAAM,IAAI,IAAI,uBAAY,EAAE;IAC/B,gBAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,IAAI,IAAI,uBAAY,CAAC,IAAiC,CAAC,EAAE;QAClE,gBAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;KAC5B;CACF;AAEY,QAAA,MAAM,GAAG,qBAGpB,CAAC;AACH,KAAK,MAAM,GAAG,IAAI,cAAM,EAAE;IACxB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM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IACH,QAAQ,CAAC,EAAkB;QACzB,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;CACF;AArHD,wBAqHC"}
|
package/build/pkg/gen1.d.ts
CHANGED
|
@@ -39,10 +39,11 @@ export declare class Side implements Gen1.Side {
|
|
|
39
39
|
get(slot: Slot): Pokemon | undefined;
|
|
40
40
|
get lastUsedMove(): ID | undefined;
|
|
41
41
|
get lastSelectedMove(): ID | undefined;
|
|
42
|
-
get
|
|
42
|
+
get lastMoveIndex(): 1 | 2 | 3 | 4 | undefined;
|
|
43
|
+
get lastMoveCounterable(): boolean;
|
|
43
44
|
toJSON(): Gen1.Side;
|
|
44
45
|
static init(gen: Generation, lookup: Lookup, team: Partial<PokemonSet>[], data: DataView, offset: number): void;
|
|
45
|
-
static encode(gen: Generation, lookup: Lookup, battle: Data<Gen1.Battle>, side: Gen1.Side, data: DataView, offset: number): void;
|
|
46
|
+
static encode(gen: Generation, showdown: boolean, lookup: Lookup, battle: Data<Gen1.Battle>, side: Gen1.Side, data: DataView, offset: number): void;
|
|
46
47
|
}
|
|
47
48
|
export declare class Pokemon implements Gen1.Pokemon {
|
|
48
49
|
static Volatiles: {
|
|
@@ -77,11 +78,11 @@ export declare class Pokemon implements Gen1.Pokemon {
|
|
|
77
78
|
toxic: number;
|
|
78
79
|
};
|
|
79
80
|
private get sleep();
|
|
80
|
-
private get
|
|
81
|
+
private get ext();
|
|
81
82
|
private get toxic();
|
|
82
83
|
toJSON(): Gen1.Pokemon;
|
|
83
84
|
static init(gen: Generation, lookup: Lookup, set: Partial<PokemonSet>, data: DataView, offset: number, index: number): void;
|
|
84
|
-
static encodeStored(gen: Generation, lookup: Lookup, pokemon: Gen1.Pokemon, data: DataView, offset: number): void;
|
|
85
|
+
static encodeStored(gen: Generation, showdown: boolean, lookup: Lookup, pokemon: Gen1.Pokemon, data: DataView, offset: number): void;
|
|
85
86
|
static encodeActive(gen: Generation, lookup: Lookup, battle: Data<Gen1.Battle>, pokemon: Gen1.Pokemon | undefined, data: DataView, offset: number): void;
|
|
86
87
|
}
|
|
87
88
|
export declare class StoredPokemon {
|