Berserk 14 for the browser, as served by Chessy (chessy.uk)
============================================================

This is the complete corresponding source for the Berserk engine files Chessy serves under
/engines/berserk/ (berserk-mt.js, berserk.js, berserk.wasm). Berserk is free software by
Jay Honnold, licensed under the GNU General Public License v3.0 (see upstream/LICENSE).

upstream/
    Berserk release 14, unmodified: https://github.com/jhonnold/berserk, tag 14,
    commit 8ae895a6151695be4a50d4fb65b0c131659c513a.

patches/berserk-14-wasm.patch
    Our only change to Berserk's source: 58 added lines in 3 files, all inside
    #ifdef __EMSCRIPTEN__, so a native build of the patched tree is identical to upstream.
      - src/nn/evaluate.c     WebAssembly has no .incbin, so the network is bundled as a file
                              in Emscripten's virtual file system and read with Berserk's own
                              LoadNetwork().
      - src/uci.c             There is no stdin in a browser: UCI lines arrive through an
                              exported function, berserk_input(), into a queue that the UCI
                              thread reads.
      - src/pyrrhic/stdendian.h   WebAssembly is little-endian.

build.ps1
    The exact build: Emscripten 6.0.12, -O3 -flto -msimd128 -msse4.1 -pthread
    -sPROXY_TO_PTHREAD -sPTHREAD_POOL_SIZE=5, the network embedded with --embed-file.
    It clones tag 14, applies the patch, downloads and checks the network, and links.
    Chessy serves the "sse41" variant.

web/berserk-mt.js
    The browser worker Chessy talks to: UCI text in, one line per message out.

The network (not modified, not included here because it is an unchanged upstream file):
    berserk-9b84c340af7e.nn, 25,201,924 bytes
    https://github.com/jhonnold/berserk-networks/releases/download/networks/berserk-9b84c340af7e.nn
    sha256 9b84c340af7e45f6e07f0046235ccb327f4ae0840c8ee2c4b97b99121e5c5084

Check: the browser build's `bench` gives 2811728 nodes, Berserk 14's own release signature,
so it searches and evaluates exactly like the native engine.
