Rubik's Cube

Posted By: Rei_Ayanami

Rubik's Cube - 03/25/10 14:58

Hello all grin

I want to present you, my work I did for school tongue.


It is a Rubik's Cube game. The gameplay is already working, but I am still at adding features like the Skin Editor and the loading/saving system. I know that this is a very bpring game/idea - but my teacher didn't want to believe me that I could program that tongue

At the moment I am waiting for a resonse for this. The skin Editor itself already works, but since it is useless to create a skin-pack without being able to apply it is really bad...

I am planning to add some effects, and an "Action-Mode" where sometimes the screen gets black-white or the camera starts turning without the player doing something.

For sure I am not a graphical designer, so the graphics are really bad ...

I also have to admit that I never reached the end of the cube, so that i could only test the end when I set the number of turnings of the npc to 2 tongue

I also gave some test versions to my friends who really helped me to improve it laugh

So now, some screens:




Done:
# building the cube dynamicly
# good camera movement (based on what my friends said)
# basic turning
# npc that turns the cube
# menu that works with mouse and keyboard
# high- and low-res cube
# loading screen with loading %


Doing at the moment:
# adding a good skin editor
# adding effects
# adding "action mode"


ToDo:
# implenting Helping system with algrythm for the shortest way
# adding better graphics
# somethings that motivate the player



Thanks for reading laugh


Download:


Posted By: Machera

Re: Rubik's Cube - 03/25/10 16:58

how about rubik's 360? i think its a good game idea but script mechanism will be harder.
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/25/10 17:38

hm...
i don't want to change the main thing, because it is only a school project wink
Posted By: Redeemer

Re: Rubik's Cube - 03/25/10 17:46

Quote:
I know that this is a very boring game/idea - but my teacher didn't want to believe me that I could program that

Hehe; prove your teacher wrong. Someday us programmers will rule the world! tongue
Posted By: Superku

Re: Rubik's Cube - 03/25/10 19:29

Where is the download link? I wanna try it laugh
Posted By: Captain_Kiyaku

Re: Rubik's Cube - 03/25/10 20:58

You should add an option to use different cube sizes grin It might be easy if your script is very dynamically in detecting the finished cube. So the player can play a 3x3, 4x4, 5x5, ... cube.
Posted By: Damocles_

Re: Rubik's Cube - 03/25/10 21:07

implementing an automatic solve-algorythm is a tough job.
I would be really impressed if you could realise that.

(a solver is needed anyhow for a hint system)
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 06:26

Good morning laugh

@Superku: i will change some more small things and than i will Upload it for you wink

@Captain_Kiyaku: thanks for that idea laugh if i have enough time this weekend i will implent this laugh - but i have to admit that i have another, more important project together with Spike tongue

@Damocles:As i said , i am trying to add this grin the Problem is that i haven't Found a real algorythm yet... If i can't find One the Next days i am trying it another way (i mean that things where they explain how to get one Block to another position )


For the Next hours i am in school, so i can just search for alghorythm in the web and think about the 5x5,6x6,... thing wink

Best regards,
rei
Posted By: Pappenheimer

Re: Rubik's Cube - 03/26/10 09:43

I was programming a puzzle game _editor_ with cubes, and, there I used a different entity for each _side_ of a cube.
Maybe, this helps you to find a way to identify which color looks to which side.

Nonetheless, this is not a trivial task. I wish you good concepts to get this managed!
Posted By: Damocles_

Re: Rubik's Cube - 03/26/10 10:04

Here some Sourcode and Example sites:

http://www.math.ucf.edu/~reid/Rubik/optimal_solver.html

http://www.wrongway.org/cube/solve.html

http://en.wikibooks.org/wiki/How_to_Solve_the_Rubik%27s_Cube


Developing an Algorythm is a decent task.

Dont be disappointed if you cant get it to work, it
really is a big chunk of development required.

The simplest would be to develope a straigt forward
brute-force recursive algorythm. (its very slow but rather simple)
(testing out all possible moves up to a certain depth of
turns, and returning the chain of moves that
solves the cube at a certain point)

If you need a "demo" algorythm, and just want to
solve the cube no matter what,
just record all previous moves (all to the scramble the cube,
and all following player moves)
Then move them backwards. This way you always solve
the cube, without any AI required....
Posted By: Pappenheimer

Re: Rubik's Cube - 03/26/10 10:13

A different idea:
when producing a random start configuration of the cube, do it the way that you create the cube with every color at place as if it were solved, and then make a certain number of random 'turns' to get the start position for the player, save these steps.
When the player starts his turns save them, too.
The solution way is then, that you follow back all steps.
Okay, that's more than brute, but it is a save, although not a very satisfying, solution... smirk
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 10:21

I already thought of that, pappenheimer.

But i think it would kill the fun tongue

Another way I thought about: A "help" mode, which shows a message if the player makes a wrong step - what do you think about that?
Posted By: Damocles_

Re: Rubik's Cube - 03/26/10 10:33

You need a solution with "right" steps before determining if a step is wrong.
So this can only come after you have an algorythm.
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 11:29

I do have the steps which the computer generated wink

This steps, i can follow inverted wink

But thanks for the links you gave me laugh
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 12:10

I have uploaded a demo to my dropbox:

http://dl.dropbox.com/u/5000845/Rubik%27s%20Cube.rar

In this demo you can just play the cube and win(or not :P). You can switch the cube resolution. The other things, like saving/loading and the skin editor aren't wokring perfectly, so they are not included wink

I really wonder how the rar can be so small, while the models are about 400 mb - lol - the rar is 5 mb tongue

Have fun and please report bugs tongue

Oh, and i also have a ToDo more - if the block is in a non x*90 angle, the clicking still works with up and down / right and left - but you will see laugh
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 14:26

Cowabanga told me that it is too slow(the turning of the cubes)

So I made that update, you can change the things in the update, than the cube will turn faster wink

http://dl.dropbox.com/u/5000845/Rubik%27s%20Cube%20-%20Update.rar
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/26/10 18:04

I am sorry about the pictures in the skin folder tongue
Posted By: Superku

Re: Rubik's Cube - 03/27/10 21:41

I've tested your program and when you get used to the controls it works quite nicely. But before I was finished,
"Du hast gewonnen!"
appeared. All mini-cubes have been at their correct position but the orientation of the 4 corner cubes belonging to the green layer were still wrong, this needs to be checked, too!

I would not try to implement a hint system because of the amount of time that has to be invested into that. Instead, I would add a how-to-solve-the-cube tutorial so people learn to solve the goold old Rubik's Cube instead of repeatedly clicking the "Hint" button.

Keep on the good work!
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/27/10 21:55

Thank you laugh

Sorry for the winning thing. I never tested it longer than 5 minutes -> i am not able to finish it ^^
--> but this is no real problem since i can check the angles laugh

Since I still got no response at my question about skin checking - you will have to wait for that xD
Posted By: Saturnus

Re: Rubik's Cube - 03/27/10 23:33

Well done!

I was agreeably surprised by the controls. In fact I found them pretty comfortable.

The memory footprint seems to be a little large, though. Perhaps I'm wrong, but I think that 280MB is pretty much for such a game.

And maybe you could use external textures for your cube models. Then they wouldn't waste so much disk space.

It's just a vague idea, but perhaps you could play a sound when the cubes click into place after they were rotated. An "Einrast-Geräusch", you know? ; )
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/28/10 10:38

Thank you Saturnus laugh

I know that the size is pretty big, but the "splitMdls.exe" which was made by a forum user, always chrashes when i set the mode to external textures -.-

Maybe I am going to make that by hand...

The thing with the sound is no problem - i just need to find a good one tongue

One question: 280 mb you wrote? Not 480 mb ? There are 3 different Qualities, one can be removed, so that I get to 300 again. But as I said, i am going to make external textures, as soon as possible laugh

edit: I think I found the problem why the splitMdls.exe chrashes. I am trying something now laugh
Posted By: Saturnus

Re: Rubik's Cube - 03/28/10 15:47

Yes, according to the task manager it consumes about 280MB.

BTW: Perhaps you can find a fitting sound on flashkit.com?
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/29/10 11:14

So, thanks Saturnuns.

I found a out what I have to do with the splitMdls.exe and now it works. 120 kb each model(before ~5mb) and memory consumption is much lower laugh

However, so I can program, with a work around, the skin editor laugh

The low poly version takes: 70 mb
and the high poly version: 82 mb

laugh
Posted By: Rei_Ayanami

Re: Rubik's Cube - 03/29/10 14:23

Hello laugh

I am making a new post, cause this is very exciting for me laugh

The skin editor works laugh

You can create you own skin packages now laugh

The only thing i need to implent is the skin loading(to edit it, apply it)

But here is a pic, of a skinned cube using my skin editor(used my 4chan images folder xD)


Posted By: PlayStefan

Re: Rubik's Cube - 07/22/11 23:39

Hi all,

I know this thread is over a year old but I have a question dealing with this topic. I have just started to code the rubik´s cube and I have a small problem.

At first I must say that I am new to 3DGS.

I have created the cube´s model and began to code the "rotating"-stuff, starting with one side to test it. The code looks like this:

Code:
...
	ecksteinWeissGruenOrange.group = 1;
	kantensteinWeissGruen.group = 1;
	ecksteinWeissGruenRot.group = 1;
	kantensteinGruenRot.group = 1;
	ecksteinGelbGruenRot.group = 1;
	kantensteinGelbGruen.group = 1;
	ecksteinGelbGruenOrange.group = 1;
	kantensteinGruenOrange.group = 1;
	mittelsteinGruen.group = 1;
		
	while( 1 )
	{
		c_ignore( 1, 0 );
		c_rotate( ecksteinWeissGruenOrange, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( kantensteinWeissGruen, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( ecksteinWeissGruenRot, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( kantensteinGruenRot, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( ecksteinGelbGruenRot, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( kantensteinGelbGruen, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( ecksteinGelbGruenOrange, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( kantensteinGruenOrange, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		c_rotate( mittelsteinGruen, vector(0,time_step*4,0), IGNORE_PUSH | USE_AXIS );
		
		wait( 1 );
	}
        ...



The code works fine but I have one big problem. If the program runs for a while the nine cube´s start to move into each other. I think this is because there is a small delay between the c_rotate functions for these nine cube parts so that they do not really rotate with the same speed.

At the moment I use 3 different cube models which I copy to build the whole cube itself. One centerpiece (6 skins), one edgepiece (12 skins) and one cornerpiece (8 skins).

How could I rotate a whole side of a cube?

Please help me.
Posted By: Rei_Ayanami

Re: Rubik's Cube - 07/23/11 00:10

I did not use c_rotate, i adjusted the pan directly, so if c_rotate is the problem, i have no idea.

Also, my rotate code was a real mess and it was way too big and unoptimized D:
Posted By: PlayStefan

Re: Rubik's Cube - 07/23/11 13:54

Thanks for your answer.

I will try do do the rotation changing the angles directly, too.

Does someone know how to do it with usage of c_rotate or maybe ent_rotate?
Posted By: Rackscha

Re: Rubik's Cube - 07/24/11 15:03

if you work with c_rotate, it acts the same way as c_move. Doing collision while rotatin, blocking while colliding, sliding on collision. SO you might want to use pan/tile/roll instead because collision is absolutely not needed. C_Rotate only when collision on rotation is needed wink
© 2024 lite-C Forums