Skip to content

Commit

Permalink
[rome] Re-enable js/useBlockStatements globally by default.
Browse files Browse the repository at this point in the history
Also ran: `npx rome check --apply-suggested ./script ./src; make format`
  • Loading branch information
lgarron committed Sep 11, 2022
1 parent 95e4e11 commit c5fa224
Show file tree
Hide file tree
Showing 8 changed files with 523 additions and 237 deletions.
3 changes: 1 addition & 2 deletions rome.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"noUnusedTemplateLiteral": "off",
"useTemplate": "off",
"useSimplifiedLogicExpression": "off",
"useSingleVarDeclarator": "off",
"useBlockStatements": "off"
"useSingleVarDeclarator": "off"
},
"ts": {
"recommended": true,
Expand Down
7 changes: 5 additions & 2 deletions src/cubing/vendor/min2phase/3x3x3-min2phase.js
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,9 @@ function $initPhase2Pre(this$static) {
);
if (ret === 0 || ret > 2) {
break;
} else ret === 2 && (p2switchMask &= 4 << p2switch);
} else {
ret === 2 && (p2switchMask &= 4 << p2switch);
}
}
if (p2switchMask === 0) {
break;
Expand Down Expand Up @@ -2432,8 +2434,9 @@ function toCubieCube(f, ccRet) {
}
for (i2 = 0; i2 < 8; i2++) {
for (ori = 0; ori < 3; ori++) {
if (f[cornerFacelet[i2][ori]] === 0 || f[cornerFacelet[i2][ori]] === 3)
if (f[cornerFacelet[i2][ori]] === 0 || f[cornerFacelet[i2][ori]] === 3) {
break;
}
}
col1 = f[cornerFacelet[i2][(ori + 1) % 3]];
col2 = f[cornerFacelet[i2][(ori + 2) % 3]];
Expand Down
22 changes: 16 additions & 6 deletions src/cubing/vendor/sq12phase/sq1-solver.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ function FullCube_getSquare(obj, sq) {
sq.cornperm = get8Perm(obj.prm);
sq.topEdgeFirst = FullCube_pieceAt(obj, 0) === FullCube_pieceAt(obj, 1);
a = sq.topEdgeFirst ? 2 : 0;
for (b = 0; b < 4; a += 3, ++b)
for (b = 0; b < 4; a += 3, ++b) {
obj.prm[b] = ~~((~~FullCube_pieceAt(obj, a) >> 1) << 24) >> 24;
}
sq.botEdgeFirst = FullCube_pieceAt(obj, 12) === FullCube_pieceAt(obj, 13);
a = sq.botEdgeFirst ? 14 : 12;
for (; b < 8; a += 3, ++b)
for (; b < 8; a += 3, ++b) {
obj.prm[b] = ~~((~~FullCube_pieceAt(obj, a) >> 1) << 24) >> 24;
}
sq.edgeperm = get8Perm(obj.prm);
sq.ml = obj.ml;
}
Expand Down Expand Up @@ -656,7 +658,9 @@ function Square_$clinit() {
Square_BottomMove = [];
fact = [1, 1, 2, 6, 24, 120, 720, 5040];
Cnk = [];
for (var i = 0; i < 12; ++i) Cnk[i] = [];
for (var i = 0; i < 12; ++i) {
Cnk[i] = [];
}
Square_init();
}

Expand Down Expand Up @@ -728,23 +732,29 @@ function Square_init() {
if (SquarePrun[idxx] === check) {
++done;
SquarePrun[inv ? i : idxx] = ~~(depth << 24) >> 24;
if (inv) continue OUT;
if (inv) {
continue OUT;
}
}
idxx = idx;
for (m = 0; m < 4; ++m) {
idxx = Square_TopMove[idxx];
if (SquarePrun[(idxx << 1) | ml] === check) {
++done;
SquarePrun[inv ? i : (idxx << 1) | ml] = ~~(depth << 24) >> 24;
if (inv) continue OUT;
if (inv) {
continue OUT;
}
}
}
for (m = 0; m < 4; ++m) {
idxx = Square_BottomMove[idxx];
if (SquarePrun[(idxx << 1) | ml] === check) {
++done;
SquarePrun[inv ? i : (idxx << 1) | ml] = ~~(depth << 24) >> 24;
if (inv) continue OUT;
if (inv) {
continue OUT;
}
}
}
}
Expand Down
111 changes: 82 additions & 29 deletions src/cubing/vendor/xyzzy/fto-solver-original.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ JavaScript engines. Recent Chrome / Node releases should also work, but are not

function counter(A) {
let counts = [];
for (let a of A) counts[a] = (counts[a] || 0) + 1;
for (let a of A) {
counts[a] = (counts[a] || 0) + 1;
}
return counts;
}

Expand Down Expand Up @@ -79,15 +81,23 @@ Note: SAFETY_MARGIN must be at most 2**20.
/* Combinatoric functions */

function factorial(n) {
if (n < 2) return n;
if (n < 2) {
return n;
}
let f = 1;
for (let i = 2; i <= n; i++) f *= i;
for (let i = 2; i <= n; i++) {
f *= i;
}
return f;
}

function C(n, k) {
if (k < 0 || k > n) return 0;
if (k === 0 || k === n) return 1;
if (k < 0 || k > n) {
return 0;
}
if (k === 0 || k === n) {
return 1;
}
let c = 1;
for (let i = 0; i < k; i++) {
c = ((c * (n - i)) / (i + 1)) | 0;
Expand Down Expand Up @@ -140,7 +150,9 @@ function permutation_parity(A) {
let parity = 0;
for (let i = 0; i < n - 1; i++) {
for (let j = i; j < n; j++) {
if (A[i] > A[j]) parity ^= 1;
if (A[i] > A[j]) {
parity ^= 1;
}
}
}
return parity;
Expand All @@ -158,11 +170,16 @@ function index_to_evenpermutation(ind, n) {
perm[n - 1] = 0;
for (let i = n - 2; i >= 0; i--) {
for (let j = i + 1; j < n; j++) {
if (perm[j] >= perm[i]) perm[j]++;
else parity ^= 1;
if (perm[j] >= perm[i]) {
perm[j]++;
} else {
parity ^= 1;
}
}
}
if (parity === 1) [perm[n - 2], perm[n - 1]] = [perm[n - 1], perm[n - 2]];
if (parity === 1) {
[perm[n - 2], perm[n - 1]] = [perm[n - 1], perm[n - 2]];
}
return perm;
}

Expand Down Expand Up @@ -241,9 +258,13 @@ function random_even_permutation(n) {
function comb_to_index(l) {
let bits = l.length;
let ones = 0;
for (let i = 0; i < bits; i++) ones += +(l[i] === 1);
for (let i = 0; i < bits; i++) {
ones += +(l[i] === 1);
}
let zeros = bits - ones;
if (zeros === 0 || ones === 0 || bits === 1) return 0;
if (zeros === 0 || ones === 0 || bits === 1) {
return 0;
}
let b = C(bits - 1, ones);
let ind = 0;
for (let i = 0; zeros > 0 && ones > 0 && bits > 1; i++) {
Expand Down Expand Up @@ -373,13 +394,17 @@ function generate_comb4_lookup_tables(n, k0, k1, k2, k3) {

function compose(A, B) {
let C = [];
for (let i = 0; i < B.length; i++) C[i] = A[B[i]];
for (let i = 0; i < B.length; i++) {
C[i] = A[B[i]];
}
return C;
}

function compose3(A, B, C) {
let D = [];
for (let i = 0; i < C.length; i++) D[i] = A[B[C[i]]];
for (let i = 0; i < C.length; i++) {
D[i] = A[B[C[i]]];
}
return D;
}

Expand Down Expand Up @@ -1138,8 +1163,9 @@ function bfs(mtable, goal_states) {
function* ida_solve_gen(indices, mtables, ptables, moves_left, commute) {
let ncoords = indices.length;
let bound = 0;
for (let i = 0; i < ncoords; i++)
for (let i = 0; i < ncoords; i++) {
bound = Math.max(bound, ptables[i][indices[i]]);
}
while (bound <= moves_left) {
//console.log(`searching depth ${bound}`);
yield* ida_search_gen(indices, mtables, ptables, bound, -1, commute);
Expand All @@ -1151,20 +1177,30 @@ function* ida_search_gen(indices, mtables, ptables, bound, last, commute) {
let ncoords = indices.length;
let nmoves = mtables[0].length;
let heuristic = 0;
for (let i = 0; i < ncoords; i++)
for (let i = 0; i < ncoords; i++) {
heuristic = Math.max(heuristic, ptables[i][indices[i]]);
if (heuristic > bound) return;
}
if (heuristic > bound) {
return;
}
if (bound === 0) {
yield [];
return;
}
if (heuristic === 0 && bound === 1) return;
if (heuristic === 0 && bound === 1) {
return;
}
for (let m = 0; m < nmoves; m++) {
if (m === last) continue;
if (m < last && commute[m][last]) continue;
if (m === last) {
continue;
}
if (m < last && commute[m][last]) {
continue;
}
let new_indices = indices.slice();
for (let c = 0; c < ncoords; c++)
for (let c = 0; c < ncoords; c++) {
new_indices[c] = mtables[c][m][indices[c]];
}
let r = 1;
while (indices.some((_, i) => indices[i] !== new_indices[i])) {
let subpath_gen = ida_search_gen(
Expand All @@ -1177,7 +1213,9 @@ function* ida_search_gen(indices, mtables, ptables, bound, last, commute) {
);
while (true) {
let { value: subpath, done } = subpath_gen.next();
if (done) break;
if (done) {
break;
}
yield [[m, r]].concat(subpath);
}
for (let c = 0; c < ncoords; c++) {
Expand Down Expand Up @@ -1317,8 +1355,9 @@ function* solve_phase1_gen(facelets) {
function* phase1_ida_solve_gen(indices, mtables, ptables, moves_left) {
let ncoords = indices.length;
let bound = 0;
for (let i = 0; i < ncoords; i++)
for (let i = 0; i < ncoords; i++) {
bound = Math.max(bound, ptables[i][indices[i]]);
}
while (bound <= moves_left) {
//console.log(`searching depth ${bound}`);
yield* phase1_ida_search_gen(indices, mtables, ptables, bound, -1);
Expand All @@ -1335,15 +1374,23 @@ function* phase1_ida_search_gen(indices, mtables, ptables, bound, last) {
ptables[2][indices[2]],
); //0;
//for (let i = 0; i < ncoords; i++) heuristic = Math.max(heuristic, ptables[i][indices[i]]);
if (heuristic > bound) return;
if (heuristic > bound) {
return;
}
if (bound === 0) {
yield [];
return;
}
if (heuristic === 0 && bound === 1) return;
if (heuristic === 0 && bound === 1) {
return;
}
for (let m = 0; m < nmoves; m++) {
if (m === last) continue;
if (m === last - 4) continue;
if (m === last) {
continue;
}
if (m === last - 4) {
continue;
}
let new_indices = [];
new_indices[0] = mtables[0][m][indices[0]];
new_indices[1] = mtables[1][m][indices[1]];
Expand All @@ -1359,7 +1406,9 @@ function* phase1_ida_search_gen(indices, mtables, ptables, bound, last) {
);
while (true) {
let { value: subpath, done } = subpath_gen.next();
if (done) break;
if (done) {
break;
}
yield [[m, r]].concat(subpath);
}
new_indices[0] = mtables[0][m][new_indices[0]];
Expand Down Expand Up @@ -1724,7 +1773,9 @@ function* phase2_ida_search_gen(
return;
}
for (let m = 0; m < 4; m++) {
if (m === last) continue;
if (m === last) {
continue;
}
let new_a = a,
new_b = b,
new_ce = ce;
Expand All @@ -1746,7 +1797,9 @@ function* phase2_ida_search_gen(
);
while (true) {
let { value: subpath, done } = subpath_gen.next();
if (done) break;
if (done) {
break;
}
yield [[m, r]].concat(subpath);
}
}
Expand Down

0 comments on commit c5fa224

Please sign in to comment.