﻿ 魔方按层求解算法设计 Flowchart Design of Layer-by-Layer Method for Rubik’s Cube

Computer Science and Application
Vol. 09  No. 02 ( 2019 ), Article ID: 29011 , 8 pages
10.12677/CSA.2019.92045

Flowchart Design of Layer-by-Layer Method for Rubik’s Cube

Runchuan Liu

High School Attached to Xi’an University, Xi’an Shaanxi

Received: Feb. 6th, 2019; accepted: Feb. 19th, 2019; published: Feb. 26th, 2019

ABSTRACT

There are many methods to solve Rubik’s cube manually, such as layered method, edge method, bridge method, angle method, CFOOP method, CFOP method, and smiling face tiger method. The exhaustive search method for computer restoring Rubik’s Cube requires calculating all states of Rubik’s cube. The computational load is huge and the method’s efficiency is low. In this paper, a layer-by-layer algorithm for computer restoration of third-order Rubik’s cube is studied. First, a mathematical model is established; second, Rubik’s Cube is judged hierarchically, and then squares of each layer are restored by cyclic mode. On this basis, the flowchart for restoring each layer of Rubik’s cube is designed. The simulation results prove the feasibility of the method.

Keywords:Rubik’s Cube, Layer Method, Flow Chart, Mathematical Model

1. 引言

2. 建立数学模型

3. 求解算法框图设计

Input：待复原的魔方

Output：已复原的魔方

1 Stage 1：上层小方块复原

2 上层角块复原，算法1流程

3 上层边缘块复原，算法2流程

4 Stage 2：中层小方块复原

5 中层边缘块复原，算法3流程

6 Stage 3：下层小方块复原

7 下层角块归位，算法4流程

8 下层角块定向，算法5流程

9 下层边缘块归位，算法6流程

10 下层边缘块定向，算法7流程

11 Result：魔方复原

3.1. 魔方上层复原

Figure 1. The coordinates of the cubes

(a) (b) (c) (d)

Figure 2. Initial and target states of upper layer. (a) Initial state of module 1, (b) Target state of module 1, (c) Initial state of module 2, (d) Target state of module 2

Figure 3. Flow chart of module 1

Figure 4. Flow chart of module 2

3.2. 魔方中层复原

(a) (b)

Figure 5. Initial and target states of middle layer. (a) Initial state of module 3, (b) Target state of module 3

Figure 6. Flow chart of module 3

3.3. 魔方下层复原

Figure 7. Flow chart of module 4

(a) (b)

Figure 8. Initial and target states of corner cubes of bottom layer. (a) Initial state of module 4, (b) Target state of module 4

(a) (b)

Figure 9. Initial and target states of corner cubes of bottom layer. (a) Initial state of module 5, (b) Target state of module 5

Figure 10. Flow chart of module 5

(a) (b)

Figure 11. Initial and target states of edge cubes of bottom layer. (a) Initial state of module 6, (b) Target state of module 6

Figure 12. Flow chart of module 6

Figure 13. Initial state of edge cubes of bottom layer

Figure 14. Flow chart of module 7

4. 结束语

Flowchart Design of Layer-by-Layer Method for Rubik’s Cube[J]. 计算机科学与应用, 2019, 09(02): 406-413. https://doi.org/10.12677/CSA.2019.92045

1. 1. 魔方[EB/OL]. https://baike.baidu.com/item/魔方/5275, 2018-11-07.

2. 2. 郝航行. 基于OpenGL的魔方游戏的设计与实现[D]: [学士学位论文]. 西安:西安理工大学, 2012.

3. 3. CFOP [EB/OL]. https://baike.baidu.com/item/CFOP/10504857, 2018-11-08.

4. 4. 孟坤, 王俊, 闫桐. 一种基于经验知识的军旗博弈算法设计与实现[J]. 智能计算机与应用, 2017, 7(2): 66-69.

5. 5. 层先法[EB/OL]. https://baike.baidu.com/item/层先法/5233102, 2018-11-07.

6. 6. 盛庆华, 杜永均, 罗飞, 李辰龙, 何凯. 基于STM32机械臂解魔方算法研究[J]. 实验室研究与探索, 2017, 36(4): 20-32.

7. 7. 李泽萱, 滕旭阳, 郑艺彬, 唐日成, 徐欢潇. 基于Arduino的两臂解魔方机器人——算法设计[J]. 电脑知识与技术, 2018, 14(17): 254-256.