The constraint is enforced at every move. Stockfish can never actually play against it. The only limitation is that its internal search tree imagines unconstrained future moves, which makes its evaluation slightly off and the engine effectively weaker. For the use case (handicapping for fun) that's an acceptable tradeoffhttps://constrainedchess.vercel.app/?fen=2b1kb2%2F8%2F8%2F8%...
vunderba|1 day ago
Yes this is what I'm saying. Evaluation can be way more than just "slightly off" though and can make the evaluation MUCH weaker because it might go down "ply-routes" that aren't just suboptimal - they simply wouldn't work at all.
For example thinking it had a "move set" that lead to a checkmate but the final ply involves a bishop that is five squares away per my rule constraint mentioned earlier.
It's fine for fun but the statement that "Stockfish's skill level applies correctly" is not a true one at any moderate level of play. (above 1200 ELO).
That's why I suggested looking into Fairy which supports runtime rule variations.
vigrant|1 day ago
Fairy would help with search tree accuracy but it's not expressive enough to cover everything, you can't encode "no captures for 5 moves" in an INI config. I'd still need the JS filtering layer for dynamic constraints, so you would end up in the same place with those cases.
vigrant|1 day ago