天道酬勤,学无止境

rubiks-cube

Using Dictionaries in Python in place of Case/Switch statement

I want to randomize a rubik's cube that is initialized as complete (all colors on the correct sides). I have move functions that rotate the cube. I want to randomly pick 50 functions in a row to properly randomize it. I am doing this project to learn a little bit more about Python, since I mostly do C++ and I see there is no case/switch for Python, so I am trying a dictionary. When I make the dictionary, the code seems to execute for some reason: def random_cube(self): scramble = { 0 : self.up_turn(), 1 : self.down_turn(), 2 : self.left_turn(), 3 : self.right_turn(), 4 : self.front_turn(), 5

2021-06-14 10:36:33    分类:问答    python   random   dictionary   rubiks-cube

Python 3.2.1: exec('x = y()') sets a value in a toy example, but not in the full code

I'm using an exec() statement to set a value, like so: foo = 3 def return_4(): return 4 instruction = 'foo = return_4()' exec(instruction) # <---- WHERE THE MAGIC HAPPENS print(foo) This comes out as 4, as I expect. My program has operations for manipulating a Rubik's cube. In this stripped down version, I'll do four things: I'll instantiate a cube, filling in one face (with abbreviations for 'front top left' and 'front bottom right' and the like). I'll have a function that rotates that front face. I'll have an 'interpreter' function, which takes a cube and a list of instructions, and applies

2021-06-11 13:35:51    分类:问答    python   exec   rubiks-cube

Rotating faces Rubik's Cube C#

I've been looking around the internet for a few days now, and I can't really find an answer that i can understand well enough to rotate my Rubik's Cube. I have made my own 3D Model using Blender of a Rubik's Cube and imported it in to Unity which is what I'm going to use to rotate the faces. But I just don't seem to understand the mathematics involved in rotating a Rubik's Cube, should i use Matrices? If so how do i couple it all together for it to work? I can rotate a single side around by grouping the bricks together by faces, but the moment you turn the next face it would completely disrupt

2021-06-11 12:28:58    分类:问答    c#   rotation   unity3d   rubiks-cube

最简单的魔方编码算法?(Easiest to code algorithm for Rubik's cube?)

问题 用 Java 编写代码来解决魔方问题的相对简单的算法是什么。 效率也很重要,但次要考虑。 回答1 我发现的最简单的非平凡算法是这个: http://www.chessandpoker.com/rubiks-cube-solution.html 编码看起来并不难。 Yannick M. 的回答中提到的链接看起来也不错,但是“交叉”步骤的解决方案对我来说似乎有点复杂。 您可能想查看许多开源求解器实现。 这是一个 Python 实现。 这个 Java 小程序还包括一个求解器,并且提供了源代码。 还有一个 Javascript 求解器,也带有可下载的源代码。 Anthony Gatlin 的回答很好地说明了 Prolog 非常适合这项任务。 这是一篇关于如何编写自己的 Prolog 求解器的详细文章。 它使用的启发式方法特别有趣。 回答2 执行随机操作,直到获得正确的解决方案。 最简单的算法,效率最低。 回答3 可能想看看:http://peter.stillhq.com/jasmine/rubikscubesolution.html 具有求解 3x3x3 魔方的算法的图形表示 回答4 我知道您的问题与 Java 相关,但实际上,Prolog 之类的语言更适合解决魔方之类的问题。 我认为这可能是针对一门课程的,您可能没有选择工具的余地。 回答5 您可以通过执行 BFS(广度优先搜索

2021-06-05 03:19:33    分类:技术分享    java   algorithm   rubiks-cube

Solving Rubik's Cubes for Dummies

Mr. Dum: Hello, I'm very stupid but I still want to solve a 3x3x3 Rubik's cube. Mr. Smart: Well, you're in luck. Here is guidance to do just that! Mr. Dum: No that won't work for me because I'm Dum. I'm only capable of following an algorithm like this. pick up cube look up a list of moves from some smart person while(cube is not solved) perform the next move from list and turn the cube as instructed. If there are no more turns in the list, I'll start from the beginning again. hey look, it's solved! Mr. Smart: Ah, no problem here's your list! Ok, so what sort of list would work for a problem

2021-06-03 03:38:21    分类:问答    algorithm   rubiks-cube

Easiest to code algorithm for Rubik's cube?

What would be a relatively easy algorithm to code in Java for solving a Rubik's cube. Efficiency is also important but a secondary consideration.

2021-05-15 23:24:27    分类:问答    java   algorithm   rubiks-cube

Visually correct rotation with OpenGl and touch screen capabilities

I have been trying to do Cube of Rubik for android. I have one question about rotations. I want to rotate a figure visually correct. It means if user touch screen and after move his finger to right a figure rotate to right from side of observation point. But when I make some rotations the figure start move in not correct direction. I understand that it depends on that axis are change their situation. But I tried to use inverse model matrix to get necessary coordinates, but I haven't already result. Could anybody give me example or link of visually correct rotation of 3D figure with help of

2021-05-12 14:34:13    分类:问答    android   opengl-es   rubiks-cube

Solving Rubik's cube programmatically

I am trying to develop a program for solving a Rubik's cube in C. I used back tracking technique for this. It is a very long process and it takes lot of iterations, so I'm not able to solve it. Please give me suggestions on how to solve this more efficiently - such as other techniques or adopting backtracking itself. In Google I found a lot of shortcuts for solving this but I don't want to solve this by using shortcuts.

2021-04-09 02:47:06    分类:问答    c   algorithm   rubiks-cube

How would you represent a Rubik's Cube in code?

If you were developing software to solve a Rubik's Cube, how would you represent the cube?

2021-04-08 00:38:25    分类:问答    data-structures   rubiks-cube