Rubik Unbound: History

It was a dark and stormy night... well, more like a boring Friday afternoon really. I had learned enough Java to use off-screen image buffers, draw filled polygons, select custom colors and respond to mouse events. Sun Microsystems' Java site had a demo applet featuring a 3D wireframe cube that could be rotated, almost realistically, by clicking and dragging. I figured, "Hey, I could do that!" and started putting together a rotatable solid cube whose faces were drawn dark or bright gray depending on their orientation towards a theoretical light source.

That didn't take long. It was just a bunch of linear algebra combined with a shading model I'd read about in a computer graphics book.

It looked pretty good to me and I could have stopped there, but then I recalled a Java implementation of Rubik's Cube I had seen a while back. That one had a very simple user interface -- a fixed cube with three plainly visible sides and the remaining three sort of floating in the air next to it. If you clicked and dragged on it, there would be a sound effect and the colors of the dragged segment got shifted 90 degrees. No animation. No frills. Merely an abstraction of the vital parts of the cube's behavior.

I don't know about you folks, but personally I've never quite liked that approach to game/puzzle design. No matter its possible technical perfection, it doesn't capture the feeling of the original. A long-time programmer might not find the differences between that cube and the real thing relevant, but I do and I expected most normal people would as well.

Then it dawned on me that I might, just might, be able to combine my current rotatable, illuminated cube with the Rubik functionality. If it worked, the result would be really stunning. It was definitely worth a try.

That weekend my mind was almost completely occupied with the cube. The first difficulty was creating a "clean" and convenient user interface. Plain rotation had to be performed by clicking and dragging, or the cube would lose too much of its feeling of flexibility. But the same principle applied to twisting. Both operations deserved to be simple enough to carry out with the mouse alone. Requiring the user to, for example, hold down the SHIFT key to distinguish between them would spoil the illusion of a genuine Rubik's Cube.

By now you will have seen how I solved the problem. The downside of my approach was that I couldn't make the middle segment twistable (or there wouldn't be any directions left for rotation), but that felt like a rather small price. People normally don't do that with real cubes anyway.

The other difficulty was how to represent a lifelike Rubik's Cube inside a Java applet. I had almost no prior experience with this type of 3D graphics and I knew I had to come up with a simple solution or the programming task would become overwhelming. Eventually I decided to try, to the greatest extent possible, to work with it only in terms of rotational directions and neighboring sides. All references would be relative and all faces of the cube would be conceptually equal. That meant freeing the cube of its worldly co-ordinates. Hence the name "Rubik Unbound".

And it worked. On the following Monday, after two days of immense concentration and hacking, there was only the fine-tuning left to do. The current look and size are the result of testing the applet on a Sun SPARCstation 10, with not a lot of speed and a relatively dark display. It was slightly bigger during its development stage but I later shrank it down until it felt fast enough in Netscape 2.01.

The applet had to look like the real thing too. A proper illumination model was only half of it. Something I had liked about the original was the way the colored patches didn't cover the sub-faces completely, so that there were thick, black edges around them and not just near-infinitely thin lines like on most web cubes. I cut off 10% on each side of the applet's colored patches, letting the black surface underneath shine though. That seemed to do the trick.

The scramble and restore options were added a couple of days later. I don't think I have ever been quite as pleased with any of my creations. Sun's 1996 Java programming competition was still on, but it was too late for me to enter. I had neglected to pre-register for it a couple of months earlier, thinking there wasn't any chance I'd learn enough of the language in time to produce a competitive applet anyway. Such is life.