解魔方编程 [英] Solving Rubik's cube programmatically

查看:164
本文介绍了解魔方编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个程序来解决魔方在C.我用回追踪技术这一点。这是一个非常漫长的过程,它需要大量的迭代,所以我不能够解决这个问题。

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.

推荐答案

为什么不使用人性化的解决方案和程序这一点。

Why not use a human oriented solution and program this.

您需要一些模式匹配,但它不会那么难。 (此外,还有一些解决方案的1000x1000x1000)。

You need some pattern matching, but it won't be that hard. (Besides there are programs solving the 1000x1000x1000).

的基本思想是在阶段工作:

The basic idea is to work in phases:

  • 第一层
  • 第二层
  • 第三层

有关每一层你实现了几个该回合模式X到模式X算法。 在一个阶段的每一步应该把立方体接近解决。可以通过添加一个值给每个图案(值越高被给予更多的未解决的立方体)执行此操作。您还可以添加一个困难(例如圈数),所以你可以选择根据每个难度最大的价值增益的算法(或达到用最少轮的最好成绩)。

For each layer you implement a couple of algorithms that turn pattern X into pattern X'. Each step in a phase should bring the cube close to solving. You can do this by adding a value to each pattern (where higher values are given to more unsolved cubes). You can also add a difficulty (for example the number of turns) so you can select an algorithm based on the best value gain per difficulty (or reach the best result with the least turns).

这种方法的有趣的是,如果你喜欢你可以添加新的算法和测试它们是如何经常​​被使用。所以,你可以测试每个算法的有效性。

The fun of this approach, is that you can add new algorithms if you like and test how often they are used. So you can test the usefulness of each algorithm.

如果你真的想赢得这些geekpoints,创建一个单独的语言来描述的算法,他们正在解决的模式。

If you really want to earn those geekpoints, create a separate language to describe the algorithms and the pattern they are solving.

这篇关于解魔方编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆