<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8" -->

---
title: From constraint models to playable puzzle games | daily.dev
description: A constraint-programming researcher describes how a desire to play a few Sudoku instances from a 434,201-puzzle corpus grew into nine browser-playable puzzle...
canonical: https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: From constraint models to playable puzzle games | daily.dev
og:description: A constraint-programming researcher describes how a desire to play a few Sudoku instances from a 434,201-puzzle corpus grew into nine browser-playable puzzle...
og:url: https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8
og:image: https://api.daily.dev/og/posts/f3qPshGB8.png
og:image:alt: From constraint models to playable puzzle games
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# From constraint models to playable puzzle games

**[Lobsters](https://daily.dev/sources/lobsters)** · 20 min read · 0 upvotes · 0 comments

## Summary

A constraint-programming researcher describes how a desire to play a few Sudoku instances from a 434,201-puzzle corpus grew into nine browser-playable puzzle games: Sudoku, Nonogram, Queens, Zip, Loopy, Tents, Patches, Wend, and Swend. Each game is backed by a MiniZinc constraint model and a Gecode-powered offline generator that ensures unique solutions. The post details the generation strategy for each game — including counterexample-guided repair, clue removal while preserving uniqueness, and exact-cover checking — along with difficulty classification via propagation and shaving configurations, and a hint system that distinguishes deduction-based hints from solution reveals.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://zayenz.se/blog/post/constraint-generated-puzzle-games>

## Questions this post answers

### How do you ensure a generated puzzle has a unique solution using constraint programming?

Uniqueness is enforced by running a solver and stopping as soon as a second solution is found. Different games use different strategies: Sudoku, Loopy, and Patches remove clues while re-checking uniqueness after each removal; Queens, Zip, and Tents study a counterexample and repair the puzzle to eliminate it; Nonogram and Wend/Swend reject candidates that fail the uniqueness check outright. Generation and checking happen offline; the browser only receives static puzzles.

_Developers building puzzle generators track uniqueness techniques and constraint-solver patterns on daily.dev._

### How does the Zip puzzle generator decide which numbered checkpoints and hedges to place?

The Zip generator starts with only the first and last numbers, then asks the solver for a second valid path. It studies that counterexample and adds a numbered checkpoint whose position in the intended path differs from its position in the alternative. When a single number cannot distinguish the two paths, a pair of numbers is added. A hedge is placed only when numbers cannot separate the counterexample within the clue-density limit. The process repeats until the intended path is the only solution.

_Puzzle and game developers exploring counterexample-guided generation find related constraint-programming techniques on daily.dev._

### How can MiniZinc model a Nonogram puzzle using the regular constraint?

Each row and column clue — a list of run lengths a, b, …, z — is converted to the regular expression '0* 1^a 0+ 1^b 0+ … 0+ 1^z 0*', where 1 is a filled cell and 0 is empty. MiniZinc compiles that string into a finite-state machine, and the built-in 'regular' global constraint enforces that every row and column matches its corresponding automaton. This approach, originally used in the Gecode nonogram example, handles rows and columns with different numbers of runs without padding.

_Developers learning constraint modeling for logic puzzles find MiniZinc examples and discussions on daily.dev._

## Similar posts on daily.dev

- [Puzzle Games That Sharpen a Developer’s Mental Modeling Skills](https://daily.dev/posts/puzzle-games-that-sharpen-a-developer-s-mental-modeling-skills-pnpsklxrq) · Atomic Spin · 0 upvotes · 0 comments
- [How my 2yo taught me constraint solving](https://daily.dev/posts/how-my-2yo-taught-me-constraint-solving-zbbt3a4f8) · Hacker News · 1 upvotes · 0 comments
- [A Dumb Introduction to z3](https://daily.dev/posts/a-dumb-introduction-to-z3-4yrba9xly) · Lobsters · 0 upvotes · 0 comments
- [Tupo](https://daily.dev/posts/tupo-rvnhxznra) · Dave Rupert · 0 upvotes · 0 comments

---

[View this post on daily.dev](https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"From constraint models to playable puzzle games","url":"https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8"},"datePublished":"2026-08-08T11:17:58.000Z","dateModified":"2026-08-08T11:18:29.756Z","description":"A constraint-programming researcher describes how a desire to play a few Sudoku instances from a 434,201-puzzle corpus grew into nine browser-playable puzzle...","image":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","thumbnailUrl":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"","timeRequired":"PT20M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"From constraint models to playable puzzle games"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/from-constraint-models-to-playable-puzzle-games-f3qpshgb8#faq","mainEntity":[{"@type":"Question","name":"How do you ensure a generated puzzle has a unique solution using constraint programming?","acceptedAnswer":{"@type":"Answer","text":"Uniqueness is enforced by running a solver and stopping as soon as a second solution is found. Different games use different strategies: Sudoku, Loopy, and Patches remove clues while re-checking uniqueness after each removal; Queens, Zip, and Tents study a counterexample and repair the puzzle to eliminate it; Nonogram and Wend/Swend reject candidates that fail the uniqueness check outright. Generation and checking happen offline; the browser only receives static puzzles. Developers building puzzle generators track uniqueness techniques and constraint-solver patterns on daily.dev."}},{"@type":"Question","name":"How does the Zip puzzle generator decide which numbered checkpoints and hedges to place?","acceptedAnswer":{"@type":"Answer","text":"The Zip generator starts with only the first and last numbers, then asks the solver for a second valid path. It studies that counterexample and adds a numbered checkpoint whose position in the intended path differs from its position in the alternative. When a single number cannot distinguish the two paths, a pair of numbers is added. A hedge is placed only when numbers cannot separate the counterexample within the clue-density limit. The process repeats until the intended path is the only solution. Puzzle and game developers exploring counterexample-guided generation find related constraint-programming techniques on daily.dev."}},{"@type":"Question","name":"How can MiniZinc model a Nonogram puzzle using the regular constraint?","acceptedAnswer":{"@type":"Answer","text":"Each row and column clue — a list of run lengths a, b, …, z — is converted to the regular expression '0* 1^a 0+ 1^b 0+ … 0+ 1^z 0*', where 1 is a filled cell and 0 is empty. MiniZinc compiles that string into a finite-state machine, and the built-in 'regular' global constraint enforces that every row and column matches its corresponding automaton. This approach, originally used in the Gecode nonogram example, handles rows and columns with different numbers of runs without padding. Developers learning constraint modeling for logic puzzles find MiniZinc examples and discussions on daily.dev."}}]}
```

