@pkmn/engine 0.1.0-dev.6195e056 → 0.1.0-dev.6344ceb5
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/LICENSE +1 -3
- package/README.md +190 -78
- package/build/pkg/addon/browser.d.ts +3 -0
- package/build/pkg/addon/browser.js +47 -0
- package/build/pkg/addon/browser.js.map +1 -0
- package/build/pkg/addon/node.d.ts +3 -0
- package/build/pkg/addon/node.js +110 -0
- package/build/pkg/addon/node.js.map +1 -0
- package/build/pkg/addon/wasm.d.ts +2 -0
- package/build/pkg/addon/wasm.js +53 -0
- package/build/pkg/addon/wasm.js.map +1 -0
- package/build/pkg/addon.d.ts +29 -0
- package/build/pkg/addon.js +80 -0
- package/build/pkg/addon.js.map +1 -0
- package/build/pkg/data/ids.json +12 -12
- package/build/pkg/data/layout.json +40 -5
- package/build/pkg/data/protocol.json +84 -13
- package/build/pkg/data.d.ts +28 -7
- package/build/pkg/data.js +3 -5
- package/build/pkg/data.js.map +1 -1
- package/build/pkg/gen1.d.ts +18 -20
- package/build/pkg/gen1.js +76 -51
- package/build/pkg/gen1.js.map +1 -1
- package/build/pkg/index.d.ts +57 -103
- package/build/pkg/index.js +23 -70
- package/build/pkg/index.js.map +1 -1
- package/build/pkg/protocol.d.ts +24 -3
- package/build/pkg/protocol.js +127 -104
- package/build/pkg/protocol.js.map +1 -1
- package/build/tools/debug.js +110 -0
- package/build/tools/debug.js.map +1 -0
- package/build/tools/display/debug.jsx +152 -0
- package/build/tools/display/debug.jsx.map +1 -0
- package/build/tools/display/index.js +152 -0
- package/build/tools/display/index.js.map +1 -0
- package/build/tools/display/ui.jsx +359 -0
- package/build/tools/display/ui.jsx.map +1 -0
- package/build/tools/display/util.js +33 -0
- package/build/tools/display/util.js.map +1 -0
- package/build.zig +417 -160
- package/package.json +93 -133
- package/src/bin/install-pkmn-engine +85 -42
- package/src/bin/pkmn-debug +62 -0
- package/src/lib/bindings/c.zig +255 -0
- package/src/lib/bindings/node.zig +121 -0
- package/src/lib/bindings/wasm.zig +59 -0
- package/src/lib/common/array.zig +77 -0
- package/src/lib/common/battle.zig +17 -0
- package/src/lib/common/data.zig +19 -31
- package/src/lib/common/debug.zig +105 -0
- package/src/lib/common/js.zig +120 -0
- package/src/lib/common/optional.zig +71 -0
- package/src/lib/common/options.zig +18 -3
- package/src/lib/common/protocol.zig +947 -407
- package/src/lib/common/rational.zig +597 -0
- package/src/lib/common/rng.zig +31 -24
- package/src/lib/common/util.zig +76 -0
- package/src/lib/gen1/calc.zig +962 -0
- package/src/lib/gen1/chance.zig +1185 -0
- package/src/lib/gen1/data/moves.zig +203 -193
- package/src/lib/gen1/data/species.zig +6 -8
- package/src/lib/gen1/data/types.zig +11 -12
- package/src/lib/gen1/data.zig +101 -90
- package/src/lib/gen1/helpers.zig +139 -54
- package/src/lib/gen1/mechanics.zig +1445 -924
- package/src/lib/gen2/calc.zig +153 -0
- package/src/lib/gen2/chance.zig +902 -0
- package/src/lib/gen2/data/items.zig +15 -23
- package/src/lib/gen2/data/moves.zig +665 -573
- package/src/lib/gen2/data/species.zig +3 -5
- package/src/lib/gen2/data/types.zig +138 -36
- package/src/lib/gen2/data.zig +134 -99
- package/src/lib/gen2/generated.zig +801 -0
- package/src/lib/gen2/helpers.zig +59 -44
- package/src/lib/gen2/mechanics.zig +3582 -30
- package/src/lib/node.zig +18 -0
- package/src/lib/pkmn.zig +93 -12
- package/src/lib/wasm.zig +17 -0
- package/src/tools/display/dom.ts +93 -0
- package/src/tools/display/ui.css +354 -0
- package/src/lib/binding/node.zig +0 -229
- package/src/lib/binding/wasm.zig +0 -10
- package/src/lib/gen1/README.md +0 -777
- package/src/lib/gen2/README.md +0 -309
package/LICENSE
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021-2023 pkmn contributors
|
|
1
|
+
Copyright (c) 2021-2025 pkmn contributors
|
|
4
2
|
|
|
5
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
4
|
this software and associated documentation files (the "Software"), to deal in
|
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<br />
|
|
4
4
|
<br />
|
|
5
5
|
<a href="https://github.com/pkmn/engine/actions/workflows/test.yml">
|
|
6
|
-
<img alt="Test Status" src="https://github.com/pkmn/engine/workflows/
|
|
6
|
+
<img alt="Test Status" src="https://github.com/pkmn/engine/actions/workflows/test.yml/badge.svg" />
|
|
7
7
|
</a>
|
|
8
8
|
<a href="#status">
|
|
9
9
|
<img alt="WIP" src="https://img.shields.io/badge/status-WIP-red.svg" />
|
|
@@ -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,19 @@ $ 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,
|
|
61
|
+
though tracks Zig's master branch so this may change in the future if breaking language changes are
|
|
62
|
+
introduced. Note that **due to a [bug in the Zig
|
|
63
|
+
compiler](https://github.com/ziglang/zig/issues/17768), compiling with a version of Zig before
|
|
64
|
+
`0.12.0-dev.876+aaf46187a` is recommended for performance**. Alternatively, building a version of
|
|
65
|
+
[Zig from source](https://github.com/ziglang/zig/wiki/Building-Zig-From-Source) after having applied
|
|
66
|
+
a [patch](zig.patch) to revert [ziglang/zig#17391](https://github.com/ziglang/zig/pull/17391) will
|
|
67
|
+
restore performance while allowing modern Zig features to be used.
|
|
55
68
|
|
|
56
69
|
`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
|
-
|
|
70
|
+
`libpkmn-showdown` library. Furthermore, protocol message logging can be enabled through `-Dlog`.
|
|
71
|
+
The `libpkmn` and `libpkmn-showdown` objects available in the binary release are both compiled with
|
|
72
|
+
the `-Dlog` flag by default.
|
|
60
73
|
|
|
61
74
|
### `@pkmn/engine`
|
|
62
75
|
|
|
@@ -67,44 +80,111 @@ $ npm install @pkmn/engine
|
|
|
67
80
|
```
|
|
68
81
|
|
|
69
82
|
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
|
|
83
|
+
`node_modules/@pkmn/engine/build/lib` to be useful. When you install the package a [`postinstall`
|
|
84
|
+
lifecycle script](https://docs.npmjs.com/cli/v8/using-npm/scripts) runs
|
|
85
|
+
[`install-pkmn-engine`](src/bin/install-pkmn-engine) which checks for a compatible `zig` compiler
|
|
86
|
+
(see earlier regarding minimum version) and download one to `node_module/@pkmn/engine/build/bin` if
|
|
87
|
+
it can't find one, as well as looking for (and downloading, if necessary) the required Node headers
|
|
88
|
+
needed to successfully build the addons natively.
|
|
89
|
+
|
|
90
|
+
**If you have configured `npm` to `--ignore-scripts` you must either run `npx install-pkmn-engine`
|
|
78
91
|
directly or build the addons manually and place the artifacts in the expected paths.**
|
|
79
92
|
|
|
80
93
|
### `pkmn`
|
|
81
94
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
To include `pkmn`, add it as a dependency in your project's
|
|
96
|
+
[`build.zig.zon`](https://github.com/ziglang/zig/blob/master/doc/build.zig.zon.md) using [Zig's
|
|
97
|
+
Package Management
|
|
98
|
+
system](https://ziglang.org/download/0.11.0/release-notes.html#Package-Management):
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
```zig
|
|
102
|
+
.dependencies = .{
|
|
103
|
+
.pkmn = .{
|
|
104
|
+
.url = "https://github.com/pkmn/engine/archive/RELEASE.tar.gz",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Replace `RELEASE` with the tag for the [release](https://github.com/pkmn/engine/releases) you wish
|
|
110
|
+
to use (e.g. `0.1.0` or `nightly`) or the specific hash of any commit. Next, run `zig build` and
|
|
111
|
+
copy the expected hash from the error message into your `build.zig.zon` alongside the `.url`:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
$ zig build
|
|
115
|
+
error: dependency is missing hash field
|
|
116
|
+
.url = "https://github.com/pkmn/engine/archive/nightly.tar.gz",
|
|
117
|
+
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
118
|
+
note: expected .hash = "122056b93b403033cb7d9bed96a02c2eb8cc1275515976167726ada6eb4207e8ef8a",
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
You must add `build.zig.zon` to the engine package to be able to import it in your `build.zig`:
|
|
122
|
+
|
|
123
|
+
<details><summary>Before v0.14.0</summary>
|
|
124
|
+
|
|
125
|
+
```zig
|
|
126
|
+
.{
|
|
127
|
+
.name = "pkmn",
|
|
128
|
+
.version = "0.1.0-dev",
|
|
129
|
+
.minimum_zig_version = "0.11.0",
|
|
130
|
+
.paths = .{
|
|
131
|
+
"build.zig",
|
|
132
|
+
"docs",
|
|
133
|
+
"LICENSE",
|
|
134
|
+
"README.md",
|
|
135
|
+
"src/include",
|
|
136
|
+
"src/lib",
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
</details>
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
<details><summary>After v0.14.0</summary>
|
|
144
|
+
|
|
145
|
+
```zig
|
|
146
|
+
.{
|
|
147
|
+
.name = .pkmn,
|
|
148
|
+
.version = "0.1.0-dev",
|
|
149
|
+
.minimum_zig_version = "0.14.0",
|
|
150
|
+
.paths = .{
|
|
151
|
+
"build.zig",
|
|
152
|
+
"docs",
|
|
153
|
+
"LICENSE",
|
|
154
|
+
"README.md",
|
|
155
|
+
"src/include",
|
|
156
|
+
"src/lib",
|
|
157
|
+
},
|
|
158
|
+
.fingerprint = 0x74a002f44f200a47,
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
</details>
|
|
162
|
+
|
|
163
|
+
Note that this hash is **not** going to be the same as the commit hash. After adding the hash to
|
|
164
|
+
your `build.zig.zon` you will be able to import the `pkmn` package's build helpers into your
|
|
165
|
+
`build.zig`:
|
|
86
166
|
|
|
87
167
|
```zig
|
|
88
168
|
const std = @import("std");
|
|
89
|
-
const pkmn = @import("lib/pkmn/build.zig");
|
|
90
169
|
|
|
91
|
-
pub fn build(b: *std.
|
|
170
|
+
pub fn build(b: *std.Build) void {
|
|
92
171
|
...
|
|
93
|
-
|
|
172
|
+
const pkmn = b.dependency("pkmn", .{ .showdown = true, .log = true });
|
|
173
|
+
exe.root_module.addImport("pkmn", pkmn.module("pkmn"));
|
|
94
174
|
...
|
|
95
175
|
}
|
|
96
176
|
```
|
|
97
177
|
|
|
98
|
-
The
|
|
99
|
-
|
|
100
|
-
|
|
178
|
+
The `pkmn` package can be configured with various options such as whether or not Pokémon Showdown
|
|
179
|
+
compatibility mode or protocol message logging should be enabled. Alternatively, you may set options
|
|
180
|
+
via a `pkmn_options` [root source file
|
|
101
181
|
declaration](https://ziglang.org/documentation/master/#Root-Source-File). There are several
|
|
102
182
|
undocumented internal options that can be tweaked as well via build or root options, though these
|
|
103
|
-
options
|
|
183
|
+
options aren't officially supported, affect correctness, and may change meaning or behavior without
|
|
104
184
|
warning. Use at your own risk.
|
|
105
185
|
|
|
106
186
|
```zig
|
|
107
|
-
pub const pkmn_options = .{ .showdown = true, .
|
|
187
|
+
pub const pkmn_options = .{ .showdown = true, .log = true };
|
|
108
188
|
```
|
|
109
189
|
|
|
110
190
|
## Usage
|
|
@@ -112,99 +192,103 @@ pub const pkmn_options = .{ .showdown = true, .trace = true };
|
|
|
112
192
|
For each Pokémon generation, the engine provides a battle structure with two functions - a function
|
|
113
193
|
to `update` the battle's state based on both players' choices and a function that defines which
|
|
114
194
|
`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
|
-
|
|
195
|
+
as their first choice to switch in the first member of their party). If `-Dlog` protocol logging is
|
|
196
|
+
enabled each update produces logs which can be decoded into a buffer (`LOGS_SIZE` constants are
|
|
197
|
+
provided to make it easy to allocate a buffer of the correct size). Each `update` returns a result
|
|
198
|
+
to indicate either that the battle has terminated or which types of choices are available for each
|
|
199
|
+
player.
|
|
120
200
|
|
|
121
201
|
Unlike [Pokémon Showdown's
|
|
122
202
|
SIM-PROTOCOL](https://github.com/smogon/pokemon-showdown/blob/master/sim/SIM-PROTOCOL.md#choice-requests)
|
|
123
203
|
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 (`
|
|
204
|
+
choices on demand based on the result of the previous `update` and the battle state (`CHOICES_SIZE`
|
|
125
205
|
is a good size to initialize the buffer passed to `choices`). **Attempting to update the battle with
|
|
126
206
|
a choice not present in the options returned by `choices` is undefined behavior and may corrupt
|
|
127
207
|
state or cause the engine to crash.**
|
|
128
208
|
|
|
129
209
|
Battles may be played out from any point but to freshly initialize a battle which is yet to start
|
|
130
210
|
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
|
|
211
|
+
Most driver code should also provide helpers to make initializing battle convenient - check the
|
|
132
212
|
respective documentation and examples for the bindings being used. The engine's [protocol
|
|
133
213
|
documentation](docs/PROTOCOL.md) goes into greater detail on the specifics of updates and the
|
|
134
214
|
potential logs that may result.
|
|
135
215
|
|
|
136
216
|
*The snippets below are meant to merely illustrate in broad strokes how the pkmn engine can be used
|
|
137
|
-
\- the [`examples`](
|
|
217
|
+
\- the [`examples`](examples) directory contains fully commented and runnable code.*
|
|
138
218
|
|
|
139
219
|
### C
|
|
140
220
|
|
|
141
221
|
[`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
|
-
|
|
222
|
+
`pkmn_` to avoid name collisions. If `-Dlog` is enabled and logging throws an error then the error
|
|
223
|
+
is encoded in the `pkmn_result` and can be checked with `pkmn_error`.
|
|
144
224
|
|
|
145
225
|
```c
|
|
146
226
|
#include <pkmn.h>
|
|
147
227
|
|
|
228
|
+
pkmn_battle_options options;
|
|
229
|
+
pkmn_gen1_battle_options_set(&options, ...);
|
|
148
230
|
pkmn_battle battle = ...;
|
|
149
|
-
|
|
231
|
+
|
|
150
232
|
pkmn_result result;
|
|
151
233
|
pkmn_choice c1 = 0, c2 = 0;
|
|
152
|
-
while (!pkmn_result_type(result = pkmn_battle_update(&battle, c1, c2,
|
|
234
|
+
while (!pkmn_result_type(result = pkmn_battle_update(&battle, c1, c2, &options))) {
|
|
153
235
|
c1 = choose(PKMN_PLAYER_P1, pkmn_result_p1(result));
|
|
154
236
|
c2 = choose(PKMN_PLAYER_P2, pkmn_result_p2(result));
|
|
237
|
+
pkmn_gen1_battle_options_set(&options, ...);
|
|
155
238
|
}
|
|
156
239
|
if (pkmn_error(result)) exit(1);
|
|
157
240
|
```
|
|
158
241
|
|
|
159
|
-
[(full code)](
|
|
242
|
+
[(full code)](examples/c/example.c)
|
|
160
243
|
|
|
161
|
-
The C API
|
|
244
|
+
The C API doesn't export any helpers for creating or accessing the opaque battle objects - it's
|
|
162
245
|
instead intended to be used as the foundation for more ergonomic bindings in [other
|
|
163
246
|
languages](#other) (the lack of namespaces and bit fields having an implementation-defined layout in
|
|
164
247
|
C are the main contributing factors to the sparseness of what `libpkmn` chooses to expose).
|
|
165
248
|
|
|
166
249
|
### JavaScript / TypeScript
|
|
167
250
|
|
|
168
|
-
`@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) which
|
|
251
|
+
`@pkmn/engine` depends on the [`@pkmn/data`](https://www.npmjs.com/package/@pkmn/data) package which
|
|
169
252
|
requires a `Dex` implementation to be provided as well. The `Battle.create` function can be used to
|
|
170
253
|
initialize a `Battle` from the beginning, or `Battle.restore` can be used to re-instantiate a battle
|
|
171
|
-
which is in
|
|
254
|
+
which is already in progress. If logging is enabled the output can be turned into Pokémon Showdown
|
|
172
255
|
protocol via `Log.parse`.
|
|
173
256
|
|
|
174
257
|
```ts
|
|
175
258
|
import {Dex} from '@pkmn/dex';
|
|
176
259
|
import {Generations} from '@pkmn/data';
|
|
177
|
-
import {Battle} from '@pkmn/engine';
|
|
260
|
+
import {Battle, Choice} from '@pkmn/engine';
|
|
178
261
|
|
|
179
262
|
const gens = new Generations(Dex);
|
|
180
263
|
const battle = Battle.create(...);
|
|
181
264
|
|
|
182
|
-
const choose = (
|
|
265
|
+
const choose = (choices: Choice[]) =>
|
|
266
|
+
choices[Math.floor(Math.random() * choices.length)];
|
|
183
267
|
|
|
184
268
|
let result: Result;
|
|
185
269
|
let c1: Choice, c2: Choice;
|
|
186
270
|
while (!(result = battle.update(c1, c2)).type) {
|
|
187
|
-
c1 = battle.
|
|
188
|
-
c2 = battle.
|
|
271
|
+
c1 = choose(battle.choices('p1', result));
|
|
272
|
+
c2 = choose(battle.choices('p2', result));
|
|
189
273
|
}
|
|
190
274
|
|
|
191
275
|
console.log(result);
|
|
192
276
|
```
|
|
193
277
|
|
|
194
|
-
[(full code)](
|
|
278
|
+
[(full code)](examples/js/example.ts)
|
|
195
279
|
|
|
196
|
-
By default, the `@pkmn/engine` package
|
|
280
|
+
By default, the `@pkmn/engine` package compiles the engine with `-Dshowdown`, though by running
|
|
197
281
|
`install-pkmn-engine` directly and passing in `--options` you can override this default and build
|
|
198
282
|
different configurations of the extension for the driver to use. The driver can support
|
|
199
283
|
configurations both with and without Pokémon Showdown compatibility simultaneously if present. On
|
|
200
|
-
update, the post-install script
|
|
284
|
+
update, the post-install script attempts to rebuild whichever extensions it finds with the same
|
|
201
285
|
configuration parameters that were originally used meaning updating to the newest version of the
|
|
202
286
|
library should be seamless.
|
|
203
287
|
|
|
204
288
|
Despite relying on the native engine code, the `@pkmn/engine` code is designed to also work in
|
|
205
289
|
browsers which support [WebAssembly](https://webassembly.org/). Running `npm run start:web` from the
|
|
206
|
-
[`examples`](
|
|
207
|
-
|
|
290
|
+
[`examples`](examples/js) directory starts a server that can be used to demonstrate the engine
|
|
291
|
+
running in the browser.
|
|
208
292
|
|
|
209
293
|
### Zig
|
|
210
294
|
|
|
@@ -215,29 +299,29 @@ be used when logging is enabled to allow for easily printing e.g. to standard ou
|
|
|
215
299
|
const std = @import("std");
|
|
216
300
|
const pkmn = @import("pkmn");
|
|
217
301
|
|
|
218
|
-
var random = std.
|
|
219
|
-
var
|
|
302
|
+
var random = std.Random.DefaultPrng.init(seed).random();
|
|
303
|
+
var choices: [pkmn.CHOICES_SIZE]pkmn.Choice = undefined;
|
|
220
304
|
|
|
221
305
|
var battle = ...
|
|
222
|
-
var
|
|
306
|
+
var options = pkmn.battle.options(...);
|
|
223
307
|
|
|
224
308
|
var c1 = pkmn.Choice{};
|
|
225
309
|
var c2 = pkmn.Choice{};
|
|
226
310
|
|
|
227
|
-
var result = try battle.update(c1, c2,
|
|
228
|
-
while (result.type == .None) : (result = try battle.update(c1, c2,
|
|
229
|
-
c1 =
|
|
230
|
-
c2 =
|
|
311
|
+
var result = try battle.update(c1, c2, &options);
|
|
312
|
+
while (result.type == .None) : (result = try battle.update(c1, c2, &options)) {
|
|
313
|
+
c1 = choices[random.uintLessThan(u8, battle.choices(.P1, result.p1, &choices))];
|
|
314
|
+
c2 = choices[random.uintLessThan(u8, battle.choices(.P2, result.p2, &choices))];
|
|
231
315
|
}
|
|
232
316
|
|
|
233
317
|
std.debug.print("{}\n", .{result.type});
|
|
234
318
|
```
|
|
235
319
|
|
|
236
|
-
[(full code)](
|
|
320
|
+
[(full code)](examples/zig/example.zig)
|
|
237
321
|
|
|
238
322
|
The Zig package also supports some APIs which are difficult to expose elsewhere such as the
|
|
239
323
|
`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
|
|
324
|
+
certain outcomes/effects always occur) for a battle, though doing so changes the size of the
|
|
241
325
|
`Battle` object.
|
|
242
326
|
|
|
243
327
|
### Other
|
|
@@ -248,12 +332,40 @@ simplify the process even further [`src/data`](src/data) contains JSON dumps of
|
|
|
248
332
|
data, structure sizes and offsets, and protocol information used by the reference driver code. The
|
|
249
333
|
following is a list of known `libpkmn` bindings written by developers outside of the [pkmn
|
|
250
334
|
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
|
|
335
|
+
necessarily be up-to-date/complete/correct - inclusion in this list doesn't imply endorsement):
|
|
252
336
|
|
|
253
|
-
| Language | License | URL
|
|
254
|
-
| ---------- | --------- |
|
|
255
|
-
| **C++** | `BSL-1.0` | https://github.com/pasyg/
|
|
256
|
-
| **Python** | `MIT` | https://github.com/AnnikaCodes/PyKMN
|
|
337
|
+
| Language | License | URL |
|
|
338
|
+
| ---------- | --------- | ------------------------------------ |
|
|
339
|
+
| **C++** | `BSL-1.0` | https://github.com/pasyg/wrapsire |
|
|
340
|
+
| **Python** | `MIT` | https://github.com/AnnikaCodes/PyKMN |
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
#### `pkmn-debug`
|
|
344
|
+
|
|
345
|
+
The [`@pkmn/engine`](#pkmnengine) package ships with a `pkmn-debug` tool which exists to decode the
|
|
346
|
+
binary data structures and protocols used by the engine and to output a [standalone
|
|
347
|
+
webpage](https://pkmn.cc/debug.html) that can be used for debugging. To use this tool in a folder
|
|
348
|
+
that has the `@pkmn/engine` package installed locally you can use `npx pkmn-debug`, though you may
|
|
349
|
+
also wish to install the package globally to be able to use this tool anywhere without
|
|
350
|
+
[`npx`](https://docs.npmjs.com/cli/v7/commands/npx):
|
|
351
|
+
|
|
352
|
+
```sh
|
|
353
|
+
$ npm install --global @pkmn/engine
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
By default, `pkmn-debug` expects to read [binary debug protocol](docs/PROTOCOL.md#debugging) from
|
|
357
|
+
[standard input](https://en.wikipedia.org/wiki/Standard_streams) and output HTML to standard output:
|
|
358
|
+
|
|
359
|
+
```sh
|
|
360
|
+
$ <cmd> | pkmn-debug > index.html
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
Alternatively, if a single filename argument is passed to the `pkmn-debug` it reads from that
|
|
364
|
+
instead:
|
|
365
|
+
|
|
366
|
+
```sh
|
|
367
|
+
$ pkmn-debug <file> > index.html
|
|
368
|
+
```
|
|
257
369
|
|
|
258
370
|
## Status
|
|
259
371
|
|
|
@@ -270,14 +382,14 @@ Currently, most of the foundational work from stage 0 is done:
|
|
|
270
382
|
|
|
271
383
|
- [benchmark and integration testing](src/test) infrastructure
|
|
272
384
|
- [documentation](docs) about design, research, methodology, etc
|
|
273
|
-
- definition and implementation of the [protocol](docs/PROTOCOL.md) that
|
|
385
|
+
- definition and implementation of the [protocol](docs/PROTOCOL.md) that's used by the engine
|
|
274
386
|
|
|
275
|
-
**Stage 1 is currently in progress** and
|
|
387
|
+
**Stage 1 is currently in progress** and involves the implementation of the actual Generation I & II
|
|
276
388
|
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
|
-
|
|
389
|
+
generations is in scope for the project but shouldn't be considered part of the immediate roadmap
|
|
390
|
+
(i.e. exploring the options for broadening support for old generation APIs is given higher priority
|
|
391
|
+
than implementing more modern generations). Furthermore, implementation of modern generations is
|
|
392
|
+
soft-blocked on the [availability of high quality
|
|
281
393
|
decompilations](https://github.com/orgs/pret/repositories) of the original games in question.
|
|
282
394
|
|
|
283
395
|
Certain features will always be deemed **out of scope**:
|
|
@@ -295,10 +407,10 @@ The pkmn engine is distributed under the terms of the [MIT License](LICENSE).
|
|
|
295
407
|
[^1]: In the case of Pokémon Showdown, only bugs which stem from a misimplementation of specific
|
|
296
408
|
effects are reproduced in the engine, bugs which are the result of a misunderstanding of the
|
|
297
409
|
fundamental mechanics of Pokémon or which simply arise due to specific Pokémon Showdown
|
|
298
|
-
implementation details that
|
|
299
|
-
choices
|
|
410
|
+
implementation details that aren't replicable without making the same (incorrect) architectural
|
|
411
|
+
choices aren't. Furthermore, the "Pokémon Showdown" code referenced by this project includes
|
|
300
412
|
several [patches](docs/TESTING.md#patches) to improve accuracy and smooth over some of the more
|
|
301
413
|
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
|
|
414
|
+
pkmn engine's compatibility mode and on this patched Pokémon Showdown simulator are the same,
|
|
415
|
+
it's only in a well defined and documented set of circumstances where the two implementations
|
|
304
416
|
diverge.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.load = load;
|
|
4
|
+
exports.loadSync = loadSync;
|
|
5
|
+
const wasm_1 = require("./wasm");
|
|
6
|
+
async function load(showdown, addon) {
|
|
7
|
+
if (typeof addon === 'string' && addon !== 'wasm') {
|
|
8
|
+
throw new Error('Unable to load native addons in the browser!');
|
|
9
|
+
}
|
|
10
|
+
let wasm;
|
|
11
|
+
if (addon instanceof WebAssembly.Instance) {
|
|
12
|
+
wasm = addon;
|
|
13
|
+
}
|
|
14
|
+
else if (addon instanceof WebAssembly.Module) {
|
|
15
|
+
try {
|
|
16
|
+
wasm = (await WebAssembly.instantiate(addon));
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (!(err instanceof Error))
|
|
20
|
+
throw err;
|
|
21
|
+
throw new Error(`Could not instantiate WASM module!\n${err.message}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const name = `pkmn${showdown ? '-showdown' : ''}.wasm`;
|
|
26
|
+
try {
|
|
27
|
+
const response = !addon || addon === 'wasm' ? fetch(name)
|
|
28
|
+
: addon instanceof URL ? fetch(addon) : addon;
|
|
29
|
+
wasm = (await WebAssembly.instantiateStreaming(response)).instance;
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (!(err instanceof Error))
|
|
33
|
+
throw err;
|
|
34
|
+
const message = !addon || addon === 'wasm'
|
|
35
|
+
? `Could not find ${name} - did you run \`npx install-pkmn-engine\`?`
|
|
36
|
+
: addon instanceof URL
|
|
37
|
+
? `Could not fetch WASM module from '${addon.href}'!`
|
|
38
|
+
: 'Could not instantiate WASM module!';
|
|
39
|
+
throw new Error(`${message}\n${err.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return (0, wasm_1.toBindings)(wasm.exports);
|
|
43
|
+
}
|
|
44
|
+
function loadSync() {
|
|
45
|
+
throw new Error('You must `initialize` the WASM addon before using the engine!');
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../../src/pkg/addon/browser.ts"],"names":[],"mappings":";;AAKA,oBAiCC;AAED,4BAEC;AAvCD,iCAAkC;AAE3B,KAAK,UAAU,IAAI,CAAC,QAAiB,EAAE,KAAgB;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,MAAM,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,IAA0B,CAAC;IAC/B,IAAI,KAAK,YAAY,WAAW,CAAC,QAAQ,EAAE,CAAC;QAC1C,IAAI,GAAG,KAAK,CAAC;IACf,CAAC;SAAM,IAAI,KAAK,YAAY,WAAW,CAAC,MAAM,EAAE,CAAC;QAC/C,IAAI,CAAC;YACH,IAAI,GAAG,CAAC,MAAM,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,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Binding = (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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.load = load;
|
|
37
|
+
exports.loadSync = loadSync;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const wasm_1 = require("./wasm");
|
|
41
|
+
const ROOT = path.join(__dirname, '..', '..', '..');
|
|
42
|
+
const LIB = path.join(ROOT, 'build', 'lib');
|
|
43
|
+
const NODE = [path.join(LIB, 'pkmn.node'), path.join(LIB, 'pkmn-showdown.node')];
|
|
44
|
+
const WASM = [path.join(LIB, 'pkmn.wasm'), path.join(LIB, 'pkmn-showdown.wasm')];
|
|
45
|
+
async function load(showdown, addon) {
|
|
46
|
+
if (addon === undefined || typeof addon === 'string' && addon !== 'wasm') {
|
|
47
|
+
try {
|
|
48
|
+
return require(!addon || addon === 'node' ? NODE[+showdown] : addon).engine;
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (!(err instanceof Error))
|
|
52
|
+
return err;
|
|
53
|
+
if (addon && addon !== 'node') {
|
|
54
|
+
throw new Error(`Unable to load native addon: '${addon}'\n${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw error(NODE[+showdown], err);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let wasm;
|
|
62
|
+
if (addon === 'wasm') {
|
|
63
|
+
try {
|
|
64
|
+
wasm = (await WebAssembly.instantiate(fs.readFileSync(WASM[+showdown]))).instance;
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
throw error(WASM[+showdown], err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else if (addon instanceof WebAssembly.Instance) {
|
|
71
|
+
wasm = addon;
|
|
72
|
+
}
|
|
73
|
+
else if (addon instanceof WebAssembly.Module) {
|
|
74
|
+
try {
|
|
75
|
+
wasm = (await WebAssembly.instantiate(addon));
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
if (!(err instanceof Error))
|
|
79
|
+
throw err;
|
|
80
|
+
throw new Error(`Could not instantiate WASM module!\n${err.message}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
try {
|
|
85
|
+
const response = addon instanceof Promise ? addon : fetch(addon);
|
|
86
|
+
wasm = (await WebAssembly.instantiateStreaming(response)).instance;
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
if (!(err instanceof Error))
|
|
90
|
+
throw err;
|
|
91
|
+
throw new Error(`Could not instantiate WASM module!\n${err.message}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return (0, wasm_1.toBindings)(wasm.exports);
|
|
95
|
+
}
|
|
96
|
+
function loadSync(showdown) {
|
|
97
|
+
try {
|
|
98
|
+
return require(NODE[+showdown]).engine;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function error(file, err) {
|
|
105
|
+
if (!(err instanceof Error))
|
|
106
|
+
return err;
|
|
107
|
+
const message = `Could not find ${path.basename(file)} addon`;
|
|
108
|
+
return new Error(`${message} - did you run \`npx install-pkmn-engine\`?\n${err.message}`);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/pkg/addon/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oBAyCC;AAED,4BAMC;AA9DD,uCAAyB;AACzB,2CAA6B;AAI7B,iCAAkC;AAElC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC;AACjF,MAAM,IAAI,GAAG,CAAC,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