-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.go
109 lines (101 loc) · 2.02 KB
/
debug.go
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"fmt"
"github.com/fatih/color"
)
func printcolor(str string) {
if str == "W" {
c := color.New(color.FgWhite)
c.Print("W")
} else if str == "R" {
c := color.New(color.FgRed)
c.Print("R")
} else if str == "O" {
c := color.New(color.FgMagenta)
c.Print("O")
} else if str == "B" {
c := color.New(color.FgBlue)
c.Print("B")
} else if str == "G" {
c := color.New(color.FgGreen)
c.Print("G")
} else if str == "Y" {
c := color.New(color.FgYellow)
c.Print("Y")
}
}
func printVerticalCube(tmpface [9]string) {
i := 0
order := [9]int{0, 1, 2, 7, 8, 3, 6, 5, 4}
for x := 0; x < 3; x++ {
for o := 0; o < 4; o++ {
fmt.Print(" ")
}
for o := 0; o < 3; o++ {
printcolor(tmpface[order[i]])
i++
}
fmt.Println()
}
fmt.Println()
}
func printMiddleCube(tmpStockface [3][9]string) {
order := [9]int{0, 1, 2, 7, 8, 3, 6, 5, 4}
for x := 0; x < 3; x++ {
for o := 0; o < 3; o++ {
printcolor(tmpStockface[x][order[o]])
}
fmt.Print(" ")
}
fmt.Println()
for x := 0; x < 3; x++ {
for o := 3; o < 6; o++ {
printcolor(tmpStockface[x][order[o]])
}
fmt.Print(" ")
}
fmt.Println()
for x := 0; x < 3; x++ {
for o := 6; o < 9; o++ {
printcolor(tmpStockface[x][order[o]])
}
fmt.Print(" ")
}
fmt.Println()
fmt.Println()
}
func debugCube(cube [6]int32) {
str := "OGBWYR" // "WROBGY"
order := [6]int{5, 3, 2, 0, 1, 4}
var tmpStockface [3][9]string
x := 0
for _, j := range order {
face := cube[j]
var tmpface [9]string
tmpface[8] = string(str[j])
for i := 7; i >= 0; i-- {
var nbr int32
nbr = face & 15
tmpface[i] = string(str[nbr])
face = face >> 4
}
if j == 5 || j == 3 || j == 4 {
printVerticalCube(tmpface)
}
if j == 2 || j == 0 || j == 1 {
tmpStockface[x] = tmpface
x++
}
if j == 1 {
printMiddleCube(tmpStockface)
}
}
}
func debugPathIDA(closedList []CubeEnv, endGrid CubeEnv) {
for i, step := range closedList[1:len(closedList)] {
fmt.Print(step.internationalMove)
if i < len(closedList)-2 {
fmt.Print(" ")
}
}
}