A JavaScript loop over 84,688 regex substitutions implements a branch-free, variable-stack virtual machine that plays 2-ply minimax chess.
Key Takeaways
The engine encodes all CPU state as a single string; each regex either manipulates a stack or reads/writes named variables embedded in that string.
Conditionals work by deactivating the %% program-start marker so all subsequent regexes silently no-op until a reactivate pattern restores it – no branches needed.
Loops are impossible by design; bounded computations like chess move generation are handled by full loop unrolling across the 84k+ regex list.
The instruction set is explicitly SIMD/branch-free, drawing design parallels to ARM predicated execution and GPU instruction sets.
Full source is on GitHub; the live demo executes the regex list client-side in the browser.