Sokoban!

Sokoban is an interesting and deep puzzle that I've been interested in for a couple of years. Solving and designing puzzles by hand is a lot of fun, and with computers, there is an added level of depth. There are some very powerful puzzle solvers and solution optimizers out there, as well as a program called YASGen that uses a genetic algorithm to generate difficult puzzles. I use JSoko and Sokoban YASC and play on Sokoban Online.

My contribution to the computer side of things is a program that finds the longest puzzles with a given goal position or a given start position. It will search the entire graph of possible positions, if enough memory is available, and print the positions it finds at the edge of its universe as well as how many moves it takes to get there. Let's call it the "pessimal program" - pessimal means worst possible, as in furthest from the goal.

Here is a collection of all the different puzzles I have made. As of 2018/09/24 they include 22 handmade puzzles already published on Sokoban Online, 56 rectangular puzzles as seen below, 31 puzzles found with the pessimal program, 17 handmade puzzle variants or ideas that weren't my best, 32 puzzles made with YASGen, for a total of 159. Note that I have a few puzzles on Sokoban Online that aren't in here, because they use that site's Modern elements like colored blocks and ice.

Longest Rectangular Puzzles

I've used a variant of my pessimal program to determine the longest possible Sokoban puzzle, in move count, that fits in a rectangular grid of a particular size. I only considered grids with no internal walls, because allowing internal walls would vastly increase the search space, and I haven't found a way to efficiently deal with that yet.

The actual algorithm is pretty simple. For a given size, loop through every possible placement of goals. For each goal, run an optimized version of the pessimal program to find out how many moves away a start position can be. The goal position with the largest possible distance, plus a start position at that distance, is the longest puzzle of that size. For the biggest of these, it took some hundreds of hours on my machine to check all possibilities.

I've also included a lot of puzzles that I haven't proved to be optimal - a lot of them probably aren't. Those puzzles are marked with a ? in the chart. Most of these sizes can't plausibly be completely searched, but these are the best positions I could find so far, using my pessimal program and trying alot of possible goal positions. To find good goal positions, I tried techniques such as manually extending a pattern, using YASGen, moving goal squares one by one and taking the best output at each point, and adding a column of goals or not-goals to a smaller rectangle in all possible ways.

There are a few patterns here that are worth noting. A rectangle always has a puzzle with at least as many moves as a smaller rectangle, because it's always possible to fill an entire edge with already-solved immovable pieces. The 2xN positions fit a pretty clear pattern, which seems to be O(N^2) - the number of moves increases quadratically in N. I also found some patterns for 3xN and 4xN, and although they take a lot of moves, they may have unimpressive long-term growth. I think the 3xN pattern here actually grows as O(N) in the long run.

The 5xN pattern is a variant of the famous 'Fibo' pattern. The number of moves to solve it grows exponentially, with a base of the golden ratio. This pattern's existence brings up some questions: are there exponential patterns for 3xN or 4xN? Are there exponential patterns that grow faster than this? Are there patterns that grow faster than exponentially?

Here are the proved longest, or longest known, Sokoban puzzles for various rectangles, along with images:

Optimal Puzzles

2x3: 5 moves

2x4: 7 moves

2x5: 14 moves

2x6: 23 moves

2x7: 31 moves

2x8: 49 moves

2x9: 57 moves

2x10: 76 moves

2x11: 84 moves

2x12: 112 moves

2x13: 120 moves

2x14: 152 moves

3x3: 14 moves

3x4: 29 moves

3x5: 49 moves

3x6: 71 moves

3x7: 101 moves

3x8: 144 moves

4x4: 70 moves

4x5: 91 moves

4x6: 206 moves

5x5: 185 moves

Suboptimal Puzzles

2x15: 160 moves or more

2x16: 197 moves or more

2x17: 205 moves or more

2x18: 252 moves or more

2x19: 260 moves or more

2x20: 307 moves or more

2x21: 315 moves or more

2x22: 373 moves or more

2x23: 381 moves or more

3x9: 167 moves or more

3x10: 208 moves or more

3x11: 252 moves or more

3x12: 259 moves or more

3x13: 314 moves or more

3x14: 318 moves or more

3x15: 376 moves or more

3x16: 380 moves or more

4x7: 234 moves or more

4x8: 330 moves or more

4x9: 343 moves or more

4x10: 374 moves or more

4x11: 484 moves or more

4x12: 485 moves or more

4x13: 530 moves or more

4x14: 614 moves or more

5x6: 305 moves or more

5x7: 334 moves or more

5x8: 347 moves or more

5x9: 527 moves or more

5x10: 861 moves or more

5x11: 1381 moves or more

5x12: 2247 moves or more

5x13: 3609 moves or more

5x14: 5830 moves or more

6x6: 331 moves or more

6x7: 485 moves or more

6x8: 892 moves or more

6x9: 1379 moves or more

6x10: 2354 moves or more

6x11: 3735 moves or more

6x12: 6170 moves or more