Show HN: Griddle – a daily logical deduction puzzle

dailygriddle.com

1 points by agambon 8 hours ago

Hey all, I made a daily logic puzzle as a passion project, and I'd love for you to test it.

If you are interested, read on for a bit of a devlog and backstory.

I have always been obsessed with logical deduction puzzles. These are my actual logic puzzle books from when I was 10 years old: https://i.imgur.com/h1HULLk.png I would spend hours doing these puzzles, and it's been on my backlog for a long time to make something that captures that feeling again.

This particular kind of grid-based logic puzzle is sometimes referred to as "Einstein's Riddle" or "a zebra puzzle". There are other online implementations of these puzzles but I personally either disliked the UX or disliked the format of the clues. For Griddle I opted for a more abstracted format, using emoji-style SVGs. So, if the categories are 'job' and 'pet', a simple clue like [Astronaut is Dog] would mean that The job 'Astronaut' has a one-to-one relationship with 'Dog' from the pet category.

Getting it to play nicely on mobile was a tricky beast, because the standard format of this kind of puzzle is a choppy grid that is as wide as it is tall, wherein every category is shown to have a relation to every other category. To solve this, I added two UX options: 'full view' and 'simple view'. In simple view, your categorical relations are presented as discrete square grids in a single column. This is very nice on mobile, but lacks the visual link that cues you into make transitive conclusions. If you opt for full view, you have to scroll left and right, but you get the full visual context of how things relate to each other transitively. The column and row headers are 'sticky' and will follow you so you don't forget the context of the cell you're looking at.

My favorite part of developing this was figuring out the logic for generating interesting, solvable puzzles with a minimum number of clues. Generating the puzzle solution matrix is easy (and all randomization is done via deterministic/seeded shuffle with the puzzle date as the seed, so re-generations are consistent). Select a number of categories, select a number of items in each, and map them uniquely one-one-one.

I defined a a number of clue types that have their own logic.

equality: A is B

inequality: A is not B

2-category XOR: A is either B or C (B and C are from same category)

and so on and so on.

Then the solver algorithm does all the work.

- generate a candidate clue of each allowed type

- filter out invalid clues

- weight the 'impact' of each clue based on how many cells it would fill

- select one with weighted (and seeded) randomization - but don't exclude clues with weight 0, because sometimes a clue is only useful later!

- iterate through all transitive and deductive logic and all past clues until no more cells are filled

- if not solved, do it again until solved

- randomize clue order

- run the solver AGAIN, this time trimming out any that don't contribute to puzzle progress

There is probably a more efficient and smarter way to do this, but it works.