5 comments

[ 3.0 ms ] story [ 17.8 ms ] thread
Interesting twist with a game I remember playing (physically) as a kid. Playing on a surface (non-rectangular) is warping my brain a bit, but I'm starting to get the hang of it.

I did notice the URL seems to be capturing the state of my board, but I can't figure out how that's done. Super fun though!

I'm using a library called react-router-dom, it gives you hooks useNavigate and useParams to write & read, respectively. Then there's some compression/stringifying of state, so you get to a hash that isn't insanely long.
Neat!

Now implement a solver using Knuth's famous Dancing Links algorithm [1].

[1] https://arxiv.org/abs/cs/0011047

Oh wow, I definitely considered a solver but I couldn't think of any reasonable way to do that. The one thing I did implement is a check if empty area === 0 mod 5, which was needed for the 'random board' option, since placing 4 area-1 tiles in an 8x8 grid can only be invalid if one of the areas has area !== 0 mod 4 (at least I think so).

That seemed like a first step towards building a solver, but I was still too intimidated by it to go any farther. But I'll take a look at this, thanks for the link!