Reputation:
I would like to create an iPhone app that can generate Hashi puzzles (if you don't know the puzzle, here's the Wikipedia article: https://en.wikipedia.org/wiki/Hashiwokakero). I think it wouldn't be too hard for me to develop a solving algorithm, however I'm not sure how to generate it.
Here's how I'd do it (idk if that even works); I generate several islands (or segments), but only if they allow a possible solution. Then, after each generated island, I run the solving algorithm through and see if it's possible to solve. If it is, done. Else, I either remove the segment and generate a different one OR add another one.
What do you think? Would this work, and are there more efficient ways of doing it?
Upvotes: 6
Views: 2784
Reputation: 96286
I would build a solution step by step, each time:
This makes sure there's a solution, but I guess a real puzzle has only one solution so later you have to verify this with a solver and maybe add/remove nodes till it satisfies this rule.
Upvotes: 4