HASHI logistic puzzle helper / solver


download HASHI program

HASHI (Hashiwokakero), also called "Bridges", is a Japanese logistic puzzle.
Below is pictured such a puzzle with (right) the solution.

The circles represent islands which have to be connected by bridges.
The number in the circle is the number of bridges connecting to the island.
Two islands my be interconnected by up to two bridges.
Bridges may not cross.
The puzzle is solved if all bridges are installed and all islands are interconnected.

Help information

(reduced picture)



menu buttons

open
Opens a file on disc.

save
Saves a puzzle on disc.
The filename is prefixed by "HASHI!_" to recognize the files.
Files do not have an extension.

new
Select "new" to add islands.
A left-mouseclick adds an island with a bridge count of one.
A next left-mouseclick increases the bridge count, a right-mouseclick decreases the bridge count.
The island disappears at a bridgecount of 0.

play
Press "play" to add / remove bridges in search for a solution.
To add a bridge:
press left-mousebutton on island and hold down.
Move mousepointer in direction of bridge.
Release mousebutton if bridge appears.
A second bridge may be added by repeating these steps.
Also, a left-mouseclick on a bridge adds a second one.
A right-mouseclick on a bridge removes a bridge.

The help buttons
With these buttons pressed, warnings and hints are generated.

warnings
With this button pressed the program warns for errors:
    1. a island is unable to attach all of the required bridges (island painted in red).
    2. a group of islands became isolated.
Below are pictured some examples:

(1) can't install bridges(2) isolated islands


Hints
The program indicates the position of a new bridge, based on logic reasoning.
Below are examples:
double bridges



4 in the corner, 6 at a side and 8 in the center.

Single bridges



3 in the corner, 5 at a side and 7 in the center.

solution
In case of very difficult puzzles, no hints are possible.
But the program is still able to provide a solution.
This process of trial and error is very time consuming.
For that reason, the number of unconnected islands is limited.
In most cases it is not posible to solve a puzzle from the very beginning,
because this would take hours.
Proceed as follows in this case:
Apply all hints and only press the "solution" button if the program fails to provide a hint.
After a solution is reported, the SPACE bar may be pressed to continue the search for a next solution.
A valid HASHI puzzle has only one unique solution.

game size
This button works if "new" is pressed.
Press left-mousebutton on game-size button, hold down while moving mousepointer up or down,
to adjust the game size.

clear
While menu:new: remove islands and bridges
While menu:play: remove the bridges

Have fun !

Hints in general

The hints mentioned before are all examples of the same general rule.

But this first:
Two islands with both the number 1 cannot have a connection because this would form an isolated group.
For the same reason two islands with both a number 2 cannot have a double connection.



Now follows the general hint rule.
Imagine an island with number B (the total number of bridges attached).
An island has four neighbours maximum which have to make these bridges possible.
We call the direction of these neighbours 1..4 (right, above, left, below).
Call ai the number of briges that may connect to heighbour i.
Let's have A = a1+a2+a3+a4



The case A < B results in a warning: the island is unable to attach all bridges.

Next, we ask the question:
"may we skip all bridges in direction 1 "
This is the case if
    a2+a3+a4>=B...of
    B <=A-a1...of
    A-B-a1>=0
For the general case of direction i:
    A - B - ai = -1 : 1 bridge missing
    A - B - ai = -2 : 2 bridges missing
If we call pi the number of bridges to paint for direction i then:
    -pi = A - B - ai, so
    pi = (B - A) + (ai - bi)
bi is the number of bridges already attached for direction i.
Negative values of p are replaced by 0.



In the example above:
    p1=p2=(5-6)+1 = 0.
    p3=p4=(5-6)+2 = 1.
The hints are painted in blue.