Skip to content

Commit

Permalink
[puzzles] Add Loopover.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Nov 18, 2023
1 parent 0865f77 commit 3e64eab
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cubing/puzzles/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const twizzleEvents: Record<string, EventInfo> = {
puzzleID: "redi_cube",
eventName: "Redi Cube",
},
loopover: {
puzzleID: "loopover",
eventName: "Loopover",
},
};

/** @category Event Info */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import type { KPuzzleDefinition } from "../../../../kpuzzle";

const o = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];

export const loopoverJSON: KPuzzleDefinition = {
name: "2x2x2",
orbits: [{ orbitName: "SQUARES", numPieces: 25, numOrientations: 3 }],
defaultPattern: {
SQUARES: {
pieces: [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24,
],
orientation: o,
},
},
moves: {
U: {
SQUARES: {
permutation: [
1, 2, 3, 4, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24,
],
orientationDelta: o,
},
},
"2U": {
SQUARES: {
permutation: [
0, 1, 2, 3, 4, 6, 7, 8, 9, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24,
],
orientationDelta: o,
},
},
"3U": {
SQUARES: {
permutation: [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 10, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24,
],
orientationDelta: o,
},
},
"4U": {
SQUARES: {
permutation: [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 15,
20, 21, 22, 23, 24,
],
orientationDelta: o,
},
},
"5U": {
SQUARES: {
permutation: [
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
21, 22, 23, 24, 20,
],
orientationDelta: o,
},
},
R: {
SQUARES: {
permutation: [
0, 1, 2, 3, 9, 5, 6, 7, 8, 14, 10, 11, 12, 13, 19, 15, 16, 17, 18, 24,
20, 21, 22, 23, 4,
],
orientationDelta: o,
},
},
"2R": {
SQUARES: {
permutation: [
0, 1, 2, 8, 4, 5, 6, 7, 13, 9, 10, 11, 12, 18, 14, 15, 16, 17, 23, 19,
20, 21, 22, 3, 24,
],
orientationDelta: o,
},
},
"3R": {
SQUARES: {
permutation: [
0, 1, 7, 3, 4, 5, 6, 12, 8, 9, 10, 11, 17, 13, 14, 15, 16, 22, 18, 19,
20, 21, 2, 23, 24,
],
orientationDelta: o,
},
},
"4R": {
SQUARES: {
permutation: [
0, 6, 2, 3, 4, 5, 11, 7, 8, 9, 10, 16, 12, 13, 14, 15, 21, 17, 18, 19,
20, 1, 22, 23, 24,
],
orientationDelta: o,
},
},
"5R": {
SQUARES: {
permutation: [
5, 1, 2, 3, 4, 10, 6, 7, 8, 9, 15, 11, 12, 13, 14, 20, 16, 17, 18, 19,
0, 21, 22, 23, 24,
],
orientationDelta: o,
},
},
},
derivedMoves: {
L: "5R'",
"2L": "4R'",
"3L": "3R'",
"4L": "2R'",
"5L": "R'",
E: "3D",
M: "3L",
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export const loopoverSVG = `<?xml version="1.0" encoding="UTF-8"?>
<svg width="600px" height="600px" viewBox="-50 -50 600 600" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>3x3x3 LL</title>
<defs>
<g id="sticker">
<rect x="0" y="0" width="100" height="100" stroke="black" stroke-width="0.5px" />
</g>
</defs>
<g id="3x3x3-LL" stroke="none" stroke-width="4" style="none" stroke-linejoin="round">
<use id="SQUARES-l0-o0" href="#sticker" transform="translate( 00, 00)" style="fill: #E23424"/>
<use id="SQUARES-l1-o0" href="#sticker" transform="translate(100, 00)" style="fill: #AC2A3C"/>
<use id="SQUARES-l2-o0" href="#sticker" transform="translate(200, 00)" style="fill: #762668"/>
<use id="SQUARES-l3-o0" href="#sticker" transform="translate(300, 00)" style="fill: #412798"/>
<use id="SQUARES-l4-o0" href="#sticker" transform="translate(400, 00)" style="fill: #152DC9"/>
<use id="SQUARES-l5-o0" href="#sticker" transform="translate( 00,100)" style="fill: #E34F27"/>
<use id="SQUARES-l6-o0" href="#sticker" transform="translate(100,100)" style="fill: #AD4D3E"/>
<use id="SQUARES-l7-o0" href="#sticker" transform="translate(200,100)" style="fill: #794E6A"/>
<use id="SQUARES-l8-o0" href="#sticker" transform="translate(300,100)" style="fill: #485399"/>
<use id="SQUARES-l9-o0" href="#sticker" transform="translate(400,100)" style="fill: #2758CA"/>
<use id="SQUARES-l10-o0" href="#sticker" transform="translate( 00,200)" style="fill: #E67A30"/>
<use id="SQUARES-l11-o0" href="#sticker" transform="translate(100,200)" style="fill: #B17A44"/>
<use id="SQUARES-l12-o0" href="#sticker" transform="translate(200,200)" style="fill: #7F7B6D"/>
<use id="SQUARES-l13-o0" href="#sticker" transform="translate(300,200)" style="fill: #547F9B"/>
<use id="SQUARES-l14-o0" href="#sticker" transform="translate(400,200)" style="fill: #3B83CB"/>
<use id="SQUARES-l15-o0" href="#sticker" transform="translate( 00,300)" style="fill: #EAA93C"/>
<use id="SQUARES-l16-o0" href="#sticker" transform="translate(100,300)" style="fill: #B8A94C"/>
<use id="SQUARES-l17-o0" href="#sticker" transform="translate(200,300)" style="fill: #89AA72"/>
<use id="SQUARES-l18-o0" href="#sticker" transform="translate(300,300)" style="fill: #63AB9E"/>
<use id="SQUARES-l19-o0" href="#sticker" transform="translate(400,300)" style="fill: #50ADCD"/>
<use id="SQUARES-l20-o0" href="#sticker" transform="translate( 00,400)" style="fill: #F1DA49"/>
<use id="SQUARES-l21-o0" href="#sticker" transform="translate(100,400)" style="fill: #C1D957"/>
<use id="SQUARES-l22-o0" href="#sticker" transform="translate(200,400)" style="fill: #95D878"/>
<use id="SQUARES-l23-o0" href="#sticker" transform="translate(300,400)" style="fill: #74D7A2"/>
<use id="SQUARES-l24-o0" href="#sticker" transform="translate(400,400)" style="fill: #64D8D0"/>
</g>
</svg>`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export { ftoSVG } from "./fto.kpuzzle.svg";
export { kilominxSVG } from "./kilominx.kpuzzle.svg";
export { rediCubeJSON } from "./redi_cube.kpuzzle.json";
export { rediCubeSVG } from "./redi_cube.kpuzzle.svg";
export { loopoverJSON } from "./loopover.kpuzzle.json";
export { loopoverSVG } from "./loopover.kpuzzle.svg";
21 changes: 21 additions & 0 deletions src/cubing/puzzles/implementations/loopover/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { KPuzzle } from "../../../kpuzzle";
import { getCached } from "../../async/lazy-cached";
import type { PuzzleLoader } from "../../PuzzleLoader";

export const loopover: PuzzleLoader = {
id: "loopover",
fullName: "Loopover",
inventedBy: ["Cary Huang"],
inventionYear: 2018,
kpuzzle: getCached(
async () =>
new KPuzzle(
(await import("../dynamic/unofficial/puzzles-dynamic-unofficial"))
.loopoverJSON,
),
),
svg: async () => {
return (await import("../dynamic/unofficial/puzzles-dynamic-unofficial"))
.loopoverSVG;
},
};
2 changes: 2 additions & 0 deletions src/cubing/puzzles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { PuzzleLoader } from "./PuzzleLoader";
import { rediCube } from "./implementations/redi-cube";
import { cube4x4x4 } from "./implementations/4x4x4";
import { melindas2x2x2x2 } from "./implementations/melindas2x2x2x2";
import { loopover } from "./implementations/loopover";

/** @category All Puzzles */
export const puzzles: Record<string, PuzzleLoader> = {
Expand Down Expand Up @@ -62,4 +63,5 @@ export const puzzles: Record<string, PuzzleLoader> = {
kilominx,
redi_cube: rediCube,
melindas2x2x2x2,
loopover,
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const puzzleIDs = {
kilominx: true,
redi_cube: true,
melindas2x2x2x2: true,
loopover: true,
};
export type PuzzleID = keyof typeof puzzleIDs;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class VisualizationStrategyProp extends TwistyPropDerived<
case "square1":
case "redi_cube":
case "melindas2x2x2x2":
case "loopover":
return "2D";
case "3x3x3":
switch (inputs.visualizationRequest) {
Expand Down
3 changes: 3 additions & 0 deletions src/sites/alpha.twizzle.net/edit/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const SCRAMBLE_EVENTS: Partial<Record<PuzzleID, string>> = {
master_tetraminx: "master_tetraminx",
kilominx: "kilominx",
redi_cube: "redi_cube",
loopover: "loopover",
};

export class App {
Expand Down Expand Up @@ -635,7 +636,9 @@ class ControlPane {
"clock",
"square1",
"redi_cube",
"loopover",
"melindas2x2x2x2",
"loopover",
].includes(puzzle);
this.toolGrid.setButtonEnabled(
"solve",
Expand Down
5 changes: 5 additions & 0 deletions src/sites/alpha.twizzle.net/edit/supported-puzzles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ const puzzleData: Partial<
optgroup: OptGroup.Other,
symbol: GeometrySymbol.Square,
},
loopover: {
"2D": true,
optgroup: OptGroup.Other,
symbol: GeometrySymbol.Square,
},
};

const puzzleGroups: Record<string, { name: string; symbol: string }[]> = {};
Expand Down

0 comments on commit 3e64eab

Please sign in to comment.