{"slug": "a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening", "title": "A browser chess or board-game AI still ships its evaluation function and opening book", "summary": "A developer's writeup warns that browser-based chess and board-game engines ship their evaluation functions, search heuristics, and compressed opening books inside the public JavaScript bundle, where competitors can pretty-print the code and lift arrays of 64 numbers and centipawn constants almost unchanged. The piece recommends adjudicating rated games and official analysis server-side, keeping licensed opening books off the client, splitting the engine from the UI bundle, and applying control-flow or VM-based obfuscation to the evaluation and search-control chunk while leaving hot bitboard loops lighter. It also cautions that local engines cannot be trusted as rating authorities, since anyone can hook evaluate and force a resignation.", "body_md": "Browser chess, go, and other board-game sites often advertise a \"strong built-in engine\". The move arrives instantly, there is no server round-trip, and it works on a plane. That usually means the evaluation function, search heuristics, and a compressed opening book are sitting in the JavaScript bundle you just downloaded.\n\nIf you spent months tuning piece-square tables, mobility weights, or a book of prepared lines, every visitor — including a competing site — can take them.\n\n## \n  \n  \n  What actually ships\n\nOpen DevTools on a typical in-browser engine and you will find more than a UI:\n\n- \n**Evaluation terms** — material values, piece-square tables, king-safety weights, pawn-structure bonuses, and the taper between midgame and endgame.\n- \n**Search control** — iterative deepening limits, null-move reductions, late-move reduction tables, and the quiescence rules that stop the search from blowing up.\n- \n**Opening book** — a map of fen or hash keys to preferred moves, sometimes with weights you collected from your own games or licensed data.\n- \n**Time management** — how much of the clock the engine spends on the first move of a new line.\n- \n**Difficulty knobs** — Elo-calibration curves that \"weaken\" the engine for casual players, which are themselves valuable product work.\n\nNone of this needs to be a neural net to be worth stealing. A carefully tuned evaluation of a few kilobytes is enough to make a free widget feel premium.\n\n## \n  \n  \n  How it gets lifted\n\nAttackers do not re-implement alpha-beta. They pretty-print the bundle and look for arrays of 64 numbers, centipawn constants, or strings from well-known opening names.\n\nHere is the kind of function that is copied almost unchanged:\n\nOnce `evaluate` and `BOOK` are in a competitor's repo, your \"unique\" engine is a skin away from being theirs. Difficulty calibration is usually a thin wrapper around the same function, so even your casual mode leaks.\n\n## \n  \n  \n  What actually protects you\n\n### \n  \n  \n  Move what you can off the client\n\n- \n**Rated games, leaderboards, and \"play the official engine\"** should be adjudicated by a server-side engine. The client can animate a move the server already chose.\n- \n**Opening books you licensed or collected** belong on the server. Ship only a tiny starter book if you need instant first-move feel, and fetch the rest after a signed request.\n- \n**Puzzle ratings and \"coach\" explanations** can be generated server-side; the client only renders them.\n\n### \n  \n  \n  Protect the interactive engine that must stay local\n\nOffline mode and \"instant analysis\" still need a local function. For that chunk:\n\n- Bundle the engine separately from the React UI.\n- Apply stronger-than-mangling protection (control-flow flattening or VM-based compilation) to evaluation, search control, and the book decoder.\n- Keep the hottest bitboard loops lighter if you measure a frame-time regression; protect the decision logic first.\n- Leave source maps off the public CDN.\n- Add a few harmless, distinctive evaluation quirks so a lifted copy is recognizable.\n\n### \n  \n  \n  Do not treat the client as a rating authority\n\nIf a \"win\" is granted because the local engine resigned, anyone can hook `evaluate` and force a resignation. Official ratings must come from a server that ran, or at least verified, the game.\n\n## \n  \n  \n  Practical checklist\n\n- [ ] Rated play and official analysis are decided on the server, not only by the in-page engine.\n- [ ] Licensed or proprietary opening books are not shipped in full in the public bundle.\n- [ ] The evaluation and search-control chunk is split from the UI bundle.\n- [ ] That chunk is protected with stronger-than-Terser obfuscation (control-flow or VM).\n- [ ] Search performance is measured after protection; hot loops can be left lighter.\n- [ ] Source maps for the engine are not on the public CDN.\n- [ ] A few distinctive, harmless evaluation markers exist so you can recognize a copy.\n- [ ] Difficulty sliders cannot be turned into a grandmaster by flipping one flag in DevTools — or if they can, that mode is clearly unofficial.\n\n## \n  \n  \n  Honest limits\n\nA determined engine author will eventually recover the shape of your evaluation. Obfuscation raises the cost of a casual lift; it does not make a secret stay secret. If a number cannot be public, do not put it in JavaScript.\n\n## \n  \n  \n  Summary\n\nAn in-browser chess AI ships the work that makes it strong: the evaluation, the search policy, and often the book. Run official games on the server, protect the offline engine you have to ship, and stop pretending that a hidden `evaluate` function is a competitive moat.\n\nDisclosure: I work on [VEILVM](https://vm.ldvmp.com/?utm_source=devto&utm_medium=post&utm_campaign=chess-ai-ships-evaluation-opening-book), a JavaScript VM-protection service. Free browser tier (3 runs/day, up to 5 KB) and a Pro plan at $9/month or $79/year with API access. Try the playground at [vm.ldvmp.com](https://vm.ldvmp.com/?utm_source=devto&utm_medium=post&utm_campaign=chess-ai-ships-evaluation-opening-book).", "url": "https://wpnews.pro/news/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening", "canonical_source": "https://dev.to/veilvm/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening-book-31an", "published_at": "2026-11-25 01:09:53+00:00", "updated_at": "2026-11-25 01:15:41.817236+00:00", "lang": "en", "topics": ["developer-tools"], "entities": [], "also_reported_by": [], "takeaway": "Browser game engines leak tuned evaluation tables and opening books in the public bundle, so move rated play and licensed books server-side and apply control-flow or VM obfuscation to the local evaluation and search-control chunk while leaving hot bitboard loops lighter.", "recommendation": {"advice": "Split your in-browser engine's evaluation and search-control code from the UI bundle, obfuscate it beyond Terser, and adjudicate rated games server-side so a hooked evaluate cannot force resignations.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening", "markdown": "https://wpnews.pro/news/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening.md", "text": "https://wpnews.pro/news/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening.txt", "jsonld": "https://wpnews.pro/news/a-browser-chess-or-board-game-ai-still-ships-its-evaluation-function-and-opening.jsonld"}}