File Exchange

image thumbnail

Hex-a-hop optimal solution finder

version 1.3 (23.4 KB) by Bradley Knockel
This code attempts to find optimal solutions to the 100 levels of Hex-a-hop, and it often succeeds!

1 Download

Updated 27 Nov 2019

View Version History

View License

where to start
Look at hex_a_hop.m using MATLAB. Octave, a free imitator of MATLAB, can also "work".

Unless you are curious, there is no reason to look at any other .m files. If you ARE curious, I've done my best to make the code readable, so feel free to look at it. Due to the complex nature of the program and my less-than-perfect ability to make the code readable, you may still have some trouble!

my goal
I thought that using a computer to search for optimal solutions to the awesome open-source game called Hex-a-hop was a cool idea, so I wrote some code to do just that. The code worked great on half of the levels, and their optimal solutions are provided in the code. However, the brute force strategy I used leads to solution times that grow exponentially as levels get more complex. Many levels run in seconds, while some could take millennia. I've done my best to speed things up, but, after trying to run all levels, many reached the time limit before completing. Since I only want algorithms that guarantee that the returned solution is optimal, there is not much I can do to fix this.

more info
• Release date of this version: Nov. 2019
• Version of MATLAB I used: R2019a
• If you find bugs or have questions, leave me a message at . Here, you can also find a profoundly better C++ version of this code with many more solutions.
• This code is under the BSD license, so you can mostly do what you want with it (just make sure you give credit to me, Bradley Knockel)
• I have included the file save1.dat to be used to quickly allow you to play all Hex-a-hop levels (just replace the old save1.dat !)

Many thanks to

Cite As

Bradley Knockel (2021). Hex-a-hop optimal solution finder (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2019a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!