Rubik's cube & scene nodes

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
User avatar
kikito
Gnoblar
Posts: 11
Joined: Wed Dec 11, 2002 7:18 pm
Location: spain

Rubik's cube & scene nodes

Post by kikito »

Hello everyone!

This one is about scene nodes...

One (non-programmer) friend of mine has challenged me to create a program for solving rubik's cubes. He believes computers are not enough powerful for that or something (isn't he cute? :D).

I'll use ogre for the graphical part, of course. The thing is that I'm not quite sure about how to represent it graphically in ogrian terms.

I'll have a different entity for each one of the 9+8+9 small cubes, but then... How should I organize the Scene nodes? It would be great if I could set this so I could just turn one node every time, and the right cubes "just followed", or this is undoable and I'm forced to "regroup" the entities before every turn?

Thanks guys,
Kikito
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

i personally would do a 3 dimensional matrix

(its what, 4x4x4 cubes?)

IN that case

SceneNode* nodes[4][4][4]

each represents the cube at the current position, when you rotate a side, simply loop through and rotate all of those nodes

It might be easie to regroup them, idk, its just a suggestion
phear hingo

My Webpage
eman
Gnoblar
Posts: 5
Joined: Sat Jul 31, 2004 5:07 pm

Post by eman »

Do you mean optimal solutions (fewest number of twists)? Finding just any old solution should be fairly simple.

You might want to check out a paper from 1997 by Richard Korf on solving Rubik's cube optimally with IDA* (iterative deepening A*) http://citeseer.ist.psu.edu/korf97finding.html
(Probably still not real-time, yet, but closer (hours instead of days))

That sounds like a cool project, though. It would be cool to see it animated in 3D.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Just a note to Robomaniac : the official Rubik's cube is 3x3x3. not 4x4x4.
But it's also possible with 4, or 5, though it obviously complicates matters :)

I think making the cubes all scene nodes is a good idea; regarding how to pivot them, I'm not sure what's the best way. I don't think you can get around shuffling the node heirarchy.
User avatar
Raven
Goblin
Posts: 203
Joined: Wed Mar 23, 2005 1:07 pm
Location: Melbourne, Australia
Contact:

Post by Raven »

I think that it would be best if you just change the position of the nodes in the array, and the position is determined from the array co-ordinates.

This way after you make a move, you suffle the nodes and re-calculate the positions

Also at any one time you will only deal with two out of the three parts of the array. Remember this when coding as it will make life easier.
(I think a method of rotation were you pass in a pointer to the start of the two arrays that make up the elements that are moving will be effictive :) )

When your done put it up some were as this will be great fun to play with :D
I used up all my sick days, so I'm calling in dead.
User avatar
kikito
Gnoblar
Posts: 11
Joined: Wed Dec 11, 2002 7:18 pm
Location: spain

Post by kikito »

Hey, thanks for the input guys!

I'll then stick to the solution that regroups the nodes in a set before moving them alltogether. Of course, I'll post something in the showcase as soon as I get something to show to the world.

Kudos to all of you,

Kikito
Post Reply