forked from rockcarry/cube
-
Notifications
You must be signed in to change notification settings - Fork 0
implement a simple algorithm to solve Rubik's Cube.
License
jqk6/cube
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
不到 800 行代码,彻底搞定魔方还原问题 VC 可以编译运行,或者用 mingw 的 gcc 编译都可以 总共代码不到 800 行,还原速度在 10s 左右,当然还可以进一步优化。 一些符号的含义: F - 正面,程序运行后白色的这一面 B - 背面,黄色面 L - 左面,紫色面(标准魔方应该是橙色,但是 windows 控制台无法显示橙色,用紫色替代) R - 右面,红色面 U - 上面,蓝色面 D - 下面,绿色面 命令说明: 魔方操作命令: f - 正面顺时针旋转 f2 - 正面 180 度旋转 f' - 正面逆时针旋转 其他面以此类推: f2 f' b b2 b' u u2 u' d d2 d' l l2 l' r r2 r' init - 魔方复位 rand - 随机打乱魔方,可以直接 rand 或者 rand n,n 为随机打乱次数 input - 输入魔方状态,按照提示输入即可 solve - 自动还原魔方 help - 帮助信息 exit - 退出程序 所有命令都是用小写字母。 数据结构和算法说明: 数据结构方面,每个面都用简单的二维数组来表示。要点是六个面的旋转操作的实现,以及魔方状态的显示,和状态输入。 算法方面,主要是用到了启发式的广度优先搜索。要点在于魔方状态的评估函数,剪枝方法,搜索算法等。 当然,你还得懂魔方。 程序代码量不大,也写得足够精简,可仔细品味。如有不懂可以提问。
About
implement a simple algorithm to solve Rubik's Cube.
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- C 100.0%