-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcube.html
More file actions
200 lines (195 loc) · 10.3 KB
/
Copy pathcube.html
File metadata and controls
200 lines (195 loc) · 10.3 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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Zixing Wang">
<meta name="generator" content="Hugo 0.88.1">
<title>Commutator</title>
<link rel="canonical" href="https://getbootstrap.com/docs/5.1/examples/navbar-fixed/">
<!-- Bootstrap core CSS -->
<link href="assets/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="icon" href="assets/images/logo.ico" type="image/x-icon" />
<!-- Custom styles for this template -->
<link href="assets/dist/css/navbar-top-fixed.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href="#">Commutator</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse"
aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav me-auto mb-2 mb-md-0">
<li class="nav-item">
<a class="nav-link" href="./"> Home </a>
</li>
<li class="nav-item">
<a class="nav-link" href="introduction.html"> Introduction </a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#"> Rubik's cube </a>
</li>
<li class="nav-item">
<a class="nav-link" href="excel.html"> Excel </a>
</li>
<li class="nav-item">
<a class="nav-link" href="code.html"> Source code </a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/nbwzx/Commutator" target="blank"> Github
repository </a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html"> About </a>
</li>
</ul>
</div>
</div>
</nav>
<main class="container">
<br />
<h2 class="border-1">Decompose an algorithm in commutator notation.</h2>
<br />
<strong>Settings:</strong>
<br />
Order: <input type="text" placeholder="4" id="order" onkeyup="changeCookie()" style="text-align:center;width:2.5em">
<i class="btn btn-default material-icons"
title="order = 4 (e.g. cube)<br />order = 5 (e.g. Megaminx)<br />order = 3 (e.g. Pyraminx)<br />order = 0 means free group"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
<input class="form-check-input" type="checkbox" id="settingsOuterBracket" onclick="changeCookie()"> Outer bracket
for all commutators
<i class="btn btn-default material-icons" title="Checked [a:[b,c][d,e]]<br />Unchecked a:[[b,c]+[d,e]]"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
<input class="form-check-input" type="checkbox" id="settingsInitialReplace" onclick="changeCookie()" checked>
Initial Replace
<i class="btn btn-default material-icons" title="Replace double layer turns<br />(e.g. r → R M')"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
<input class="form-check-input" type="checkbox" id="settingsFinalReplace" onclick="changeCookie()" checked> Final
Replace
<i class="btn btn-default material-icons" title="Replace double layer turns<br />(e.g. R M' → r)"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
<input class="form-check-input" type="checkbox" id="settingsCommute" onclick="changeCookie()" checked> Commute
<i class="btn btn-default material-icons" title="Handle commute moves<br />(e.g. R and L)"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
Max Depth: <input type="text" placeholder="0" id="settingsMaxDepth" onkeyup="changeCookie()"
style="text-align:center;width:2.5em"><i class="btn btn-default material-icons"
title="Upper bound of search depth<br />0 means first solvable depth"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
Sorting rules:
<br />
The score of C:[A,B] is <input type="text" placeholder="2.5" id="settingsSortScorea" onkeyup="changeCookie()"
style="text-align:center;width:2.5em"> * stm(A) + <input type="text" placeholder="5" id="settingsSortScoreb"
onkeyup="changeCookie()" style="text-align:center;width:2.5em"> *
stm(B) + stm(C) (Suppose stm(A) ≥ stm(B), stm means slice turn metric) <i class="btn btn-default material-icons"
title="Algs are sorted by score" style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8"
data-toggle="popover" data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
Addition penalty: <input type="text" placeholder="1" id="settingsSortScoreAdd" onkeyup="changeCookie()"
style="text-align:center;width:2.5em"> <i class="btn btn-default material-icons"
title="Score for commutator combo" style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8"
data-toggle="popover" data-placement="bottom" data-bs-html="true">help_outline</i>
<br />
<input class="form-check-input" type="checkbox" id="settingsFast" onclick="changeCookie()">
Fast
<i class="btn btn-default material-icons" title="Show one result only"
style="font-size:16px;padding:0;vertical-align: middle;color:#17a2b8" data-toggle="popover"
data-placement="bottom" data-bs-html="true">help_outline</i>
<br /><br />
<div class="mb-3">
<label class="form-label"><strong>Input:</strong></label>
<input id="alg" type="text" class="form-control" placeholder="Enter an algorithm" aria-label="Enter an algorithm"
style="font-size: 30px;">
</div>
<button type="button" id="cube" class="btn btn-danger" onclick="commutatorclick()">Decompose
Me</button>
<button type="button" id="expand" class="btn btn-danger" onclick="expandclick()">Expand Me</button>
<br />
<br />
<div class="mb-3">
<label class="form-label"><strong>Output:</strong></label>
<textarea class="form-control" id="out" rows="1" style="font-size: 30px;" disabled readonly></textarea>
</div>
<br />
</main>
<script src="assets/dist/js/bootstrap.bundle.min.js"></script>
<script src="assets/dist/js/commutator.min.js"></script>
<script src="assets/dist/js/cookie.js"></script>
<script>
let popoverTriggerList = [].slice.call(
document.querySelectorAll('[data-toggle="popover"]')
);
const popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl);
});
</script>
<script>
function updateTextAreaRows() {
const textarea = document.getElementById("out");
textarea.rows = 1;
const computedStyle = window.getComputedStyle(textarea);
const lineHeight = parseInt(computedStyle.lineHeight);
const paddingTop = parseInt(computedStyle.paddingTop);
const paddingBottom = parseInt(computedStyle.paddingBottom);
const height = textarea.scrollHeight - paddingTop - paddingBottom;
textarea.rows = Math.round(height / lineHeight);
}
function commutatorclick() {
const outlist = commutator
.search({
"algorithm": document.getElementById("alg").value,
"order": Number(document.getElementById("order").value !== "" ? document.getElementById("order").value : 4),
"outerBracket": document.getElementById("settingsOuterBracket").checked,
"initialReplace": document.getElementById("settingsInitialReplace").checked ? undefined : {},
"finalReplace": document.getElementById("settingsFinalReplace").checked ? undefined : {},
"abMaxScore": Number(document.getElementById("settingsSortScorea").value !== "" ? document.getElementById(
"settingsSortScorea").value : 2.5),
"abMinScore": Number(document.getElementById("settingsSortScoreb").value !== "" ? document.getElementById(
"settingsSortScoreb").value : 5),
"addScore": Number(document.getElementById("settingsSortScoreAdd").value !== "" ? document.getElementById(
"settingsSortScoreAdd").value : 1),
"commute": document.getElementById("settingsCommute").checked ? undefined : {},
"maxDepth": Number(document.getElementById("settingsMaxDepth").value !== "" ? document.getElementById(
"settingsMaxDepth").value : 0),
"fast": document.getElementById("settingsFast").checked,
});
let outstr = "";
for (const i in outlist) {
outstr = outstr + outlist[i];
if (i < outlist.length - 1) {
outstr = outstr + "\n";
}
}
document.getElementById("out").innerHTML = outstr;
updateTextAreaRows();
}
function expandclick() {
document.getElementById("out").innerHTML = commutator
.expand({
"algorithm": document.getElementById("alg").value,
"order": Number(document.getElementById("order").value !== "" ? document.getElementById("order").value : 4),
"initialReplace": document.getElementById("settingsInitialReplace").checked ? undefined : {},
"finalReplace": document.getElementById("settingsFinalReplace").checked ? undefined : {},
"commute": document.getElementById("settingsCommute").checked ? undefined : {}
});
updateTextAreaRows();
}
</script>
</body>
</html>