Creating a Hashi Puzzle

I would like to create an iPhone app that can generate hash puzzles (if you don't know the puzzles, here is the Wikipedia article: https://en.wikipedia.org/wiki/Hashiwokakero ). I think it would not be easy for me to develop a solution algorithm, but I'm not sure how to generate it.

This is how I will do it (idk if it even works); I generate several islands (or segments), but only if they allow a possible solution. Then, after each generated island, I run the solution algorithm and see if it can be solved. If so, do it. In addition, I either delete the segment, or generate another, or add another.

What do you think? Will this work, and are there better ways to do this?

+6
source share
1 answer

I built the solution step by step, every time:

  • add node
  • add one or more bridges to it (if this is not possible, select a new node)
  • increase counters.
  • mark the places used by bridges as inaccessible.

This ensures that there is a solution, but I think that the real puzzle has only one solution, so you will have to check it with the solver and possibly add / remove nodes until it satisfies this rule.

+4
source

Source: https://habr.com/ru/post/913848/


All Articles