Comments (5)
The latest fix I made should resolve this issue. The algorithm used to generate puzzles guarantees uniqueness; there was simply a bug in the implementation.
For the record, the algorithm works as follows:
While count is less than 81:
- On the current puzzle, run all difficulty-appropriate tutor algorithms. If any are successful (meaning a square's value is forced), put that number into the internal puzzle, and increment count. Return to top of loop.
- If no algorithm succeeds, generate a random number between zero and forty, call it n. If the squares n and 80 - n are unfilled, fill them in in the internal puzzle and the puzzle to be displayed, and increment count. If n != 40, increment count again (as two squares would be filled). Return to top of loop.
The algorithm guarantees a unique solution because every square must either be filled at the start, or be deducible using one of the difficulty-appropriate algorithms (it may not be deducible immediately, but it must eventually be). The bug that was causing the problem was in step 2 of the algorithm, which did not originally check if the square n and 80 - n were filled before incrementing count. Thus, if the same squares were selected, count would be incremented without changes being made to the puzzle, and thus, ambiguity could arise.
from sdd-sudoku-teacher.
After this fix, I hit another puzzle without a unique solution. See screenshot below.
from sdd-sudoku-teacher.
Fixed with revision 1bc2ce9
from sdd-sudoku-teacher.
Not totally fixed yet... This is a moderate puzzle.
from sdd-sudoku-teacher.
I haven't seen this for a while, closing.
from sdd-sudoku-teacher.
Related Issues (12)
- Pre-generate complete puzzles at Main Menu HOT 2
- Generated "easy" puzzle may not be solvable using easy algorithms HOT 2
- Memory leak in moderate puzzle generation HOT 1
- Optimize puzzle making
- Methods to make easy and moderate puzzles can hang HOT 2
- Number of blanks HOT 1
- Max generation time
- Time in title bar HOT 1
- Hint-->Play CRASH HOT 1
- Hint crash HOT 2
- Post Puzzle Crash HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdd-sudoku-teacher.