-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCornerPatternDatabase.cpp
More file actions
46 lines (38 loc) · 1.5 KB
/
CornerPatternDatabase.cpp
File metadata and controls
46 lines (38 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by Ayushi Saha on 18-12-2022.
//
#include "CornerPatternDatabase.h"
CornerPatternDatabase::CornerPatternDatabase() : PatternDatabase(100179840) {}
CornerPatternDatabase::CornerPatternDatabase(uint8_t init_val) : PatternDatabase(100179840, init_val) {}
uint32_t CornerPatternDatabase::getDatabaseIndex(const Generic_Rubiks_Cube &cube) const {
array<uint8_t, 8> cornerPerm =
{
cube.getCornerIndex(0),
cube.getCornerIndex(1),
cube.getCornerIndex(2),
cube.getCornerIndex(3),
cube.getCornerIndex(4),
cube.getCornerIndex(5),
cube.getCornerIndex(6),
cube.getCornerIndex(7),
};
uint32_t rank = this->permIndexer.rank(cornerPerm);
array<uint8_t, 7> cornerOrientations = {
cube.getCornerOrientation(0),
cube.getCornerOrientation(1),
cube.getCornerOrientation(2),
cube.getCornerOrientation(3),
cube.getCornerOrientation(4),
cube.getCornerOrientation(5),
cube.getCornerOrientation(6),
};
uint32_t orientationNum =
cornerOrientations[0] * 729 +
cornerOrientations[1] * 243 +
cornerOrientations[2] * 81 +
cornerOrientations[3] * 27 +
cornerOrientations[4] * 9 +
cornerOrientations[5] * 3 +
cornerOrientations[6];
return (rank * 2187) + orientationNum;
}