# Pikafish in the browser

The files in this folder run the Pikafish xiangqi engine on the player's device (WebAssembly in a Web Worker).
They are separate programs: HdSpace only talks to them with UCI text messages (`pikafish.worker.js`).

## Engine (`lite/*/pikafish.js`, `lite/*/pikafish.wasm`)

- Pikafish, GPL-3.0: https://github.com/official-pikafish/Pikafish
  (upstream commit `545c4e3b251afbb94f493c6c5f32549f900e76fd`, 2026-10-18).
- WebAssembly build (Emscripten 3.1.74, with a small entry point patch) by pikafish-js, release `v1.0.0`:
  https://github.com/Maicarons/pikafish-js/releases/tag/v1.0.0
  Corresponding source, build scripts and patches: https://github.com/Maicarons/pikafish-js (tag `v1.0.0`),
  licensed AGPL-3.0-or-later.
- Licence text: `COPYING.txt`.
- Builds: `threads-simd` (several threads), `single-simd`, `single-nosimd` (old browsers), all built for L1=512.

## Network (`pikafish-lite.nnue`)

- Distilled from the official Pikafish network by pikafish-js:
  https://github.com/Maicarons/pikafish-js/releases/tag/networks
  (SHA-256 `ac223f6d20e8db0ec0ecf64b8955a834086e3eb329d52908c0730fdfba5dc97f`).
- Pikafish weights and the weights derived from them follow the Pikafish NNUE licence
  (https://github.com/official-pikafish/Networks): legal use only, **no commercial use without permission**.

Every file was checked against the `SHA256SUMS` of its release before being copied here.

The official network (L1=1024) is not shipped: `master-net` moved to a new architecture (K6H4, 2026-10-28) that
this build cannot load, and the official 2026-09-06 network does not load either (tested). A stronger option needs a
WebAssembly build of a newer Pikafish together with the network it was made for.

## Updating

Put a new release in a new folder (`v2/`) and change `ENGINE_BASE` in `src/Services/LocalEngine/Pikafish.Local.ts`:
the service worker caches these files forever (cache first), so a file must never change under the same URL.
A network only loads with the build of its own architecture: always ship and test them together.
