de·caff Brain Ball Solver
Fri, Mar 18, 2022 (latest change)
Here you’ll find a simple quick and dirty program allowing to solve the old Brain Ball puzzle.
I had this old Brain Ball lying around, not even sure who ever gave it to me many decades ago. Probably my parents after I solved the good old Rubik’s Cube when I had to spend a few days in a hospital even longer ago. I agree with the rating in the linked article that the ball is harder to solve.
Because I was a bit sick a few weeks ago I tried to solve the ball again, but again it showed that this is time-consuming, as the necessary sequence of operations is long, and getting lost on the way is easy. Basically you can solve the ball by repeating the same 3 wedge rotation operation after color-separating the sides (which is no too hard) making sure that the permutation you get is even (which again is awkward to compute by hand).
Instead, as a programmer I took up to the challenge to just write a program. Again this is not that simple as the sheer number of possible permutations are much more than any consumer class PC could handle, even if you are lucky to have one with 16 cores and 128GB as I do. Still solving just one brain ball configuration would take 100s of years with a breadth-first search algorithm.
Instead of targeting for the perfect solution a step-by-step solution seemed more promising. I.e. create an even-parity color-separated ball in the first step (that’s even fast with a breadth-first search), then try to solve for sequence 1-2-3, then 1-2-3-4-5, then 1-2-3-4-5-6-7 and so on. These 2 more wedges for each step was usually in search range for the breath-first search, also sometimes the maximum search depth was exhausted without finding it, but at least a solution adding 1 additional wedge was always found. Depending on how often exhausting happened this took from a few minutes to several hours to solve a ball, so at least I was able to find a solution for solving my physical ball.
The breadth-first search is basically performing the same search pattern again each time it is called. This leads to the idea to just find out which of the intermediate results are “useful”, i.e. which can at least possibly improve a given result.
Looking for these useful sequences finds some 80,000 of them form the maximum search depth of 16 operations which my computer can handle. Although these are only 1/2000th of the possible even-parity color-separated configurations this is enough to help solving any brain ball in less than a second.
The final algorithm is first doing a breadth-first search to a color-separated even configuration (this might take a while), and then a search through the precalculated solutions (this just needs milliseconds).
Be warned: this program is quick and dirty, there are some rough corners, and I’m not planning much time on further improving it. So take it or leave it. It does what it should: display a brain ball, allow to manipulate, and allow to solve it. It does nothing which it should not, like accessing the internet, or spying out your computer. You can load and save brain balls, and in the latter case it will write a small text file to your drive (usually less than 100 bytes).
To run the program you’ll need at least a Java 9 Runtime Environment installed.
On most operating systems double-clicking the downloaded jar file will directly start it (assuming Java is installed). If you get warnings these are basically serious: any program you download to your computer can do you harm, and although I promised that this one won’t, you’ll have to trust me with that.
If double-clicking is not doing the job you can start from the command line by
java -jar brainball.jar
in the directory where you downloaded it (or just use the jar’s complete path).
If both ways don’t work make sure Java is installed on your computer. You can download it here.
Just remove the downloaded jar file, and any files with
.bb13 extension you
happened to save deliberately. This program does not install anything in a registry
Basically the display is two-fold. Left is a brain ball which you can manipulate, and which is used to display the current state. Right is a sequence of operations on the brain ball, either stored from your manipulations or created from solving.
- You can manipulate the brain ball by clicking on it, see the description below it. This will clear whatever operations are appearing after the currently selected operation in the sequence list at the right.
- The button Input Ball (lower left) allows to input a brain ball. Just use
13for white wedges, and
-13for orange ones. Obviously each absolute number must appear exactly once.
- The button Input Sequence allows to input sequences of operations in a shorthand
notation which mostly follows the standards (example: the sequence presented at
the right is
/(a slash) stands for a twist.
- Any number stands for a rotation of the given number of tiles, with positive numbers rotating clockwise and negative numbers rotating counterclockwise. The relevant numbers are also printed around the ball.
%(a percent sign) stands for a turn-over.
- The button Optimize in the upper part of the operation sequence display (left) will exchange the given sequence with one which is optimized.
- The button Copy will copy the displayed sequence to the system clipboard, using the shorthand notation described above.
- The large Target button in the Solving section (lower right) allows to define what is considered the solution. Standard is clockwise white 1-2-3-…, with the 1 at the pole.
- The 2 Way checkbox allows to switch on or off 2-way solving. Sometimes the algorithm
will find a better solution when going backward. An example is (copy and paste to the
Input Ball dialog):
1 3 5 7 9 11 13 2 4 6 8 10 12. Assuming Multi is switched off, switching 2-way on will reduce the solution steps from 87 to 68.
- The Multi checkbox allows to switch on or off multiple start point solving. If enabled not only the visible brain ball configuration will be solved, but all which only differ by rotations or turn-over. Because of the algorithm used this may lead to better results. These are 26 configurations, and if 2 Way is also switched on, 52 brain ball configurations will be solved in the background, and the shortest one is selected as solution. This is still quite fast and is done in less than a few seconds on most computers. In the example configuration given in the last point this will reduce the solution length from 68 (with 2-way) to 44 steps.
- Last not least will the Solve button solve the currently displayed ball, i.e. it will calculate a sequence of operations which will lead from that ball to the one you defined as the target. The operations at the right will be replaced by this solution. As said the found solution is usually not an optimal one.
- You can save the currently displayed ball and sequence to a
.bb13file and reload that file later using the File menu. These files are simple text files, and if you dare to look into one you’ll see that the content is pretty straight-forward.
- You can adapt font sizes by rotating the mouse wheel over the program window while pressing Ctrl anywhere.
- You can step through the operations by rotating the mouse wheel over the ball.
Feel free to write an email. Basically I’m not planning to put more work into this program, but if you find an error let me know. I hate knowing of bugs in my code, and prefer to fix these.
Solving Your Brain Ball
If you have a physical brain ball, and you want to solve it, it’s simple:
- Click on Input Ball and input your ball’s sequence of numbers clockwise starting form the pole. Just use negative numbers for orange wedges.
- Click on Solve.
- Follow the operations step by step. To not lose track it is recommended that you step through the list of operations (right) and operate your physical ball accordingly. This allows you to compare if your ball and the one on screen are still in sync.
|March 18, 2023
|Added Multi checkbox for even shorter solutions.
|March 17, 2023
|Improved on speed and solution shortness.
|March 16, 2023
|Added a faster preparation algorithm.
|March 16, 2023
|Allows scrolling through solution via mouse wheel (over ball).
|March 16, 2023
|Allows adapting font sizes via ctrl + mouse wheel (anywhere).
|March 16, 2023
|Fixed problem with small screens where GUI wasn’t completely visible initially.
|March 15, 2023