Ken-Soft

Software and the World


Rubik’s Cube - 2D Implementation - Java

Posted under Game Development, Java, Logic Problems, Programming, Rubik's Cube, Software Development by Kenny on Thursday 25 December 2008 at 11:43 pm

Bookmark and Share

This is a simple 2D representation of a Rubik’s Cube written in Java. Its main purpose to be easily integrated with other software. I.e. A Rubik’s Cube solving Neural Network. Therefore, the UI is not extremely eye catching. But it serves a good test to demonstrate that the software is working. Later implementations will better support NxNxN cubes.

The Jar file can be downloaded here: Rubik’s Cube.jar Just click it to run it. If you have any problems running it, check to ensure that Java is correctly installed on your machine.

Rubik's Cube 2D java Rubik's Cube 2D java

RubiksCubeGUI.java

RubiksCube.java is the main wrapper class to Cube3D

RubiksCube.java

Cube3D.java

Each of the 27 cubes that make up a standard 3×3 Rubik’s Cube, I call a Cubit.

Cubit.java

Cube3DTest.java

Share on Facebook

Logical Method for Solving the 3×3x3 Rubik’s Cube

Posted under Learning, Rubik's Cube by Kenny on Wednesday 24 December 2008 at 7:29 pm

Bookmark and Share

How to Logically Solve a Rubik’s Cube

Kenneth Cason

First, as with any problem, it is important to understand what your objective is. In the case of the Rubik’s Cube, the main goal is to arrange the pieces in such a way that each side is the same color. Next lets luck at the structure of a standard 3×3 Rubik’s Cube. It is a cube composed of 6 sides, each side composed of 9 stickers (3×3). There are 8 corner pieces, 12 edge pieces and 6 center pieces (one on each side). It is also important to note that on all “odd” Rubik’s Cube’s the center pieces can rotate clockwise or counter clockwise, but the positions are fixed. “odd” meaning that the cube is a 3×3, 5×5, NxN, where N is an odd number. Also, because the center pieces are fixed it becomes immediately obvious which side is which color.
Now that we know the basic structure of a Rubik’s Cube next lets think about strategies to solve it. First, lets examine what is probably the most common way to solve a Rubik’s Cube, the “Layer by Layer” method. For those not familiar with the Layer by Layer method, it involves solving the top, middle, and bottom layer in that order. However, despite this seeming to be the most logical way to approach the Rubik’s Cube, it is actually farm more difficult to solve in this manner. The problem is very simple. If you solve the first layer completely, in order to solve the second layer without messing up the solved first layer the moves grow in length and complexity. Then to solve the bottom layer without messing up the top and middle ayers, the moves again grow even more complex. To add a quantitative example, lets look at the case of trying to place a piece in the second row without messing up the first row it takes 7 permutations, and to switch the bottom layer edge pieces positions without messing up the top and middle layers, permutations can be as much as 15, in which you are more likely to give up before you ever derive on your own techniques. Not to say that it is impossible, but without any experience cubing can prove to be very difficult. However using the method In this paper, you can place all edge pieces in their correct positions in as f approximately 3 permutations each. In a nutshell, this is where most people are mistaken, is thinking that the Layer by Layer method is the easiest way to solve a Rubik’s Cube when in fact mathematically it’s more complex to do so.
Also, until you are comfortable with the feel of a Rubik’s Cube, I highly recommend to avoid checking many websites for solutions as they primarily rely on rote memorization of techniques, though definitely useful after you’ve got a feel for the cube on your own. Plus it’s more rewarding when you do it on your own. Now, the next time you see someone solving a Rubik’s Cube using the Layer by Layer method, you can assume that about 99% of the time they learned how to solve it from either A) a friend or B) the internet. Also, contrary to popular belief, you cannot re-stick the stickers after peeling them off. As encouragement, you may also be happy to know that you need not know or understand any mathematics to solve the Rubik’s Cube. Good Luck!
Note, as I believe it spoils the reward of solving the Rubik’s Cube, I will NOT write any algorithms that will directly tell you how to move pieces as shown in the following diagrams. This guide is merely designed to guide and kindle your thoughts and let you know that there is a simpler method than the layer-by-layer method.

Explanation:
1. First, scramble up the Rubik’s Cube, if it isn’t already.

2. All except on corner piece, solve the top layer. This may seem difficult at first, but will become simple as you practice.

Rubik's Cube Tutorial
Just like in the diagram, solve the for edge pieces in the top layer, creating a cross. Ensure that the color orientation is correct all the way around by examining the center pieces color in the middle layer.
Rubik's Cube Tutorial
Next, solve any three of the corner pieces in the top layer, leaving one unsolved corner piece. You may choose to the corner to not solve at your own discretion.

3. Except for one edge piece, place corresponding 3 edge pieces into the middle layer.

Rubik's Cube Tutorial
In order to do this, we are going to make use of the unsolved corner piece in the top layer. In general you first place the unsolved corner of the top layer directly over the place in the second layer where you want to place the correct piece (which must be in the bottom layer). Then in only 3 moves each you can solve 3 of the 4 edge pieces in the middle layer. The resulting pattern should be similar to whats in the diagram to the left.

4. Next, turn the cube upside down exposing the bottom layer.

Rubik's Cube Tutorial
The unsolved 2 pieces from the top and middle layer in previous steps can now be used to place the edge pieces correctly in the bottom row.
Rubik's Cube Tutorial
If done correctly the resulting pattern will be as described in the diagram to the left.

5. Next, place the remaining corner pieces into their correct place, without regarding orientation. Typical algorithms involve the rotation of 3 corner pieces either clockwise or counterclockwise. To do so takes and algorithm of only 8 moves. Depending on probability you may even be lucky enough to solve the cube at this point by simple rotating the corners.

Rubik's Cube Tutorial
An example of a sample 3 corner rotation clockwise.

6. Finally, what may seem to be the most difficult part of the cube, rotating two corner pieces orientation. However, this is deceptively easy. As you can see in the diagram if one corners orientation is rotated clockwise, one other corner piece is rotated oppositely. This is because during the process of rotating one corner piece, the cube gets messed up. Then by performing the operations in reverse to another corner piece, it causes the cube to fix itself and rotate one other piece in the opposite direction. It can be viewed in a simpler case such as if you rotate the top face clockwise, naturally by doing the opposite and rotating the top face counterclockwise, you will fix the cube. This principle is in my opinion a key concept in understanding the Rubik’s Cube.

Rubik's Cube Tutorial
To perform the rotations shown in the diagram requires and algorithm of 14 moves. However, Don’t be alarmed, half of it is simply undoing what you did in the first half. So it’s really more like 6 moves to rotate a single corner piece in one direction, 1 move to put the next corner to rotate into position, 6 moves to undo the first 6 moves you did which causes the corner piece to rotate in the opposite direction. 1 move to readjust the top layer

The secret to the Rubik’s Cube is practice. The more you work at it the more you will understand it.
Good Luck!

PDF Download available here
Japanese Version available here here

Share on Facebook

ルービックキューブの論理的なやり方(3x3x3)

Posted under Learning, Rubik's Cube by Kenny on Wednesday 24 December 2008 at 6:17 pm

Bookmark and Share

ルービックキューブの論理的なやり方

Kenny Cason(ケン・ケーソン)

 まず、ルービックキューブの目的は同じ色を集めていくことである。それで、普通のルービックキューブの構成を教えてみよう。ルービックキューブは立方体で、各面は9個(3×3)の色の付いたシールがある。コーナキューブが8個で、エッジキューブが12個で各面の中心にあるセンターキューブが6個で構成されている。奇数のルービックキューブの中心のピースは回転するが移動しない。それゆえ、各面の正解の色が簡単に判る。次は解き方を考えてみよう。一番目、二面目、三面目をそれぞれ揃ていくという方法が一番よく使われている方法だろうが、意外にそうやって揃おうとすと、問題が出る。例えば、一面目を完全に揃えたら、二面目を揃う為に既に揃えた場所を崩さずに他の場所を揃えると、動作が非常に多くなるから、解くのももっと難しくなって、揃える前に諦める可能性がある。これは殆どの人の間違えの一つだと思う。インターネットでルービックキューブのやり方を検索すると、沢山のウェブサイトが出てくるが、殆どのウェブサイトは動作の暗記だけで、解き方はとても回りくどいだから、あまり役に立たないと思う。あと、自分で考えた方が価値があると思う。では、もっと分かりやすいやり方を教えてみよう。ルービックキューブのやり方は比較的に簡単だから、頑張って!

説明:
1。まず、ルービックキューブを回して色をバラバラに崩す。
2。一つのコーナキューブ以外、一面目を揃えていく。これを自力で出来なければ、もっと練習しなければならない。

Rubik's Cube Tutorial
こんなふうに一面目の間のピースを揃えていく。
Rubik's Cube Tutorial
それで、一面目のコーナキューブを三つ揃えていく。どれでもいい。

3。二段目のエッジキューブを三つ揃えていく。

Rubik's Cube Tutorial
まずは、一面目のまだ揃ってないコナーキューブを二面目のまだ揃ってないエッジキューブの上に回す。

4。一番下の段のエッジキューブを揃えていく。これらのキューブをそれぞれ三つの動作
で揃えていく。

Rubik's Cube Tutorial
まだ揃えてないエッジキューブを簡単に正しい場所に入れる為、一、二面目の二つの揃えてないキューブのスペースを使うコツがある。
Rubik's Cube Tutorial
ステップ4が終わったら、すべてのエッジキューブが揃えている。

5。次は、コナーキューブを揃えていく。残っているまだ揃っていないコナーキューブを正しい場所に入れていく。八回の動作で三個のコナーキューブが右・左回りに回転することができる。確率によると、一個から三個のキューブを同時に揃えることが出来る。

Rubik's Cube Tutorial
コナーキューブが揃うまで、回す。

6。最後は一番難しそうかもしれないが、意外にコナーキューブの回転のやり方は分かりやすい。一個のコナーキューブを回したら、ルービックキューブを直す為に、他のスタートポイントを前のコナーキューブと同じ場所から逆に回さなければならない。

Rubik's Cube Tutorial
十四回の動作で二個のコナーキューブを逆に回す

ルービックキューブをするにはコツは練習です。
頑張ってください!

PDFは下のリンクからダウンロードできます。
日本語:ダウンロード
英語ダウンロード

Share on Facebook

Copyright © 2009 www.Ken-Soft.com