

If a F-cost is defined, sort by minimum F-cost.The tie-breaking for the priority queue is : The memory is fully controlled in order to set a memory limit for this solver without the risk of having an overflow memory.Īfter having implemented plenty of hash functions, I finally use the default hash function for bitset and I do a XOR with the player normalized position.ĭepending of the algorithm chosen, the open queue can be : It is an open-addressing hashtable with linear probing. It helps a lot when we have no goal ordering available.Ī custom transposition table is created especially for the solver. With this enhancement, just computing the heuristic score can lead to detect new deadlocks due to a goal that is no more accessible. It is a long computation and we have to be smart to optimize this computation. To solve this problem, I recompute the heuristic after finding a frozen area. Sometimes, these areas may change the heuristic score and affect the reachability of unfilled goals. The basic heuristic is defined as the heuristic that does not take into account any other boxes.ĭuring the main search, we will find new frozen boxes on goals (otherwise it is a deadlock). Even if we use a really accurate method to find a perfect bipartite matching between boxes and goals, there are lots of situations where the basic heuristic is not sufficient. To solve sublevels, the heuristic uses the nearest goal for each box which is really fast.Īssuming that the basic heuristic is sufficient to solve a Sokoban level is an error.

The Hungarian one has been modified a bit in order to be optimized in O(n^3). It is a long computation which uses the Hungarian algorithm in O(n^4) in time complexity. If you want to find optimal solutions, use a bidirectional search with A* algorithm in both side.Īll algorithms that require a heuristic use the bipartite matching. This is the quickest way to find a solution. There is no check when the two searches overlap.īy default, Sokolution uses a bidirectional search with greedy algorithm in both side. A thread will perform the forward search and another thread will perform the backward search. The bidirectional mode is a combination of forward and backward modes. Note that the final player position should be able to reach its initial position. We start from the solution (all boxes are on goals) and we pull boxes in order to find the initial position. The backward mode is the opposite of the forward mode. This is the natural mode to solve Sokoban problems. The forward mode consists to start from the initial state and try to find a sequence of pushes to put all boxes on goals.
#PUZZLEDOM SOKOBAN SOLUTIONS FULL#
I chose C++ because it is a very fast low-level language really fast and we can have the full control of the memory thanks to the pointers.
#PUZZLEDOM SOKOBAN SOLUTIONS WINDOWS 7#
Sokolution is written in C++, uses STL library / C++14 concepts and is built with MinGW 5.1 under Windows 7 / 10.
