Question:

How to program a C (plus plus =D) rubiks cube

by  |  earlier

0 LIKES UnLike

i really need this in dumbtalk i am a n00b at C

 Tags:

   Report

3 ANSWERS


  1. I'm not going to pretend to be a C guru, but you're going to need to be a bit more descriptive than that...


  2. The actual solving algorithm I can't help you with, as I never could figure out how to solve the dang thing. Storing the model I can help a bit more with - you basically have a 6X3x3 array representing the 6 faces of the cube with each array value being a character standing for a particular color.

    Then you would likely have the following functions

    showCube() //displays the 'front' three faces of the cube

    mixFaces() //randomly execute turnSlice functions sufficient times to mix up the faces (can't just randomly populate teh array since you wouldn't necessarily have a solvable set)

    rotateX(bool clockwise) //rotate whole cube 1/4 turn in X direction clockwise or not

    rotateY(bool clockwise) //rotate whole cube 1/4 turn in Y direction clockwise or not

    rotateZ(bool clockwise) //rotate whole cube 1/4 turn in Z direction clockwise or not

    turnSlice1(bool clockwise) //turn the slice 1 section 1/4 clockwise or not

    ...

    turnSlice9(bool clockwise) //turn the slice 9 section 1/4 clockwise or not

    The only real grunt work is working out for each of the turn/rotate functions where the 54 array values need to be shifted to for a true and false parm.

  3. The key is to get the algorithm.  I would google that.  Use your main function to perform the algorithm step by step.  The best way to implement this is to write a function for each step.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.