Skip to content

Commit

Permalink
[twizzle/edit] Use real ETM (rotations count).
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jul 10, 2022
1 parent 21f0f48 commit 1c43df3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
9 changes: 9 additions & 0 deletions src/cubing/notation/CountMoves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ function baseMetric(move: Move): number {
}
}

// TODO: Implement a puzzle-specific way to calculate this.
function etmMetric(_move: Move): number {
return 1;
}

// TODO: Implement a puzzle-specific way to calculate this.
function quantumMetric(move: Move): number {
const fam = move.family;
Expand All @@ -104,6 +109,10 @@ const countMovesInstance = new CountMoves(baseMetric);
export const countMoves: (alg: Alg) => number =
countMovesInstance.traverseAlg.bind(countMovesInstance);

const countMovesETMInstance = new CountMoves(etmMetric);
export const countMovesETM: (alg: Alg) => number =
countMovesInstance.traverseAlg.bind(countMovesETMInstance);

const countQuantumMovesInstance = new CountMoves(quantumMetric);
export const countQuantumMoves: (alg: Alg) => number =
countQuantumMovesInstance.traverseAlg.bind(countQuantumMovesInstance);
1 change: 1 addition & 0 deletions src/cubing/notation/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Note: this folder is purposely not built as a package entry point (yet).

export {
countMovesETM as experimentalCountMovesETM,
countMoves as experimentalCountMoves,
countQuantumMoves as experimentalCountQuantumMoves,
} from "./CountMoves";
Expand Down
14 changes: 7 additions & 7 deletions src/sites/alpha.twizzle.net/edit/app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Alg, AlgBuilder, LineComment, Newline } from "../../../cubing/alg";
import { experimentalEnsureAlg } from "../../../cubing/alg/Alg";
import { experimentalCountMovesETM } from "../../../cubing/notation";
import { puzzles } from "../../../cubing/puzzles";
import { randomScrambleForEvent } from "../../../cubing/scramble";
import {
Expand All @@ -17,20 +18,19 @@ import {
TwistyPlayer,
TwistyPlayerConfig,
} from "../../../cubing/twisty";
import { getStickeringGroup } from "../../../cubing/twisty/model/props/puzzle/display/StickeringProp";
import type { AlgWithIssues } from "../../../cubing/twisty/model/props/puzzle/state/AlgProp";
import type { SetupToLocation } from "../../../cubing/twisty/model/props/puzzle/state/SetupAnchorProp";
import { FreshListenerManager } from "../../../cubing/twisty/model/props/TwistyProp";
import { customElementsShim } from "../../../cubing/twisty/views/node-custom-element-shims";
import "../../../cubing/twisty/views/stream/TwistyStreamSource";
import type { TwistyStreamSource } from "../../../cubing/twisty/views/stream/TwistyStreamSource";
import type { TwistyAlgEditor } from "../../../cubing/twisty/views/TwistyAlgEditor/TwistyAlgEditor";
import { URLParamUpdater } from "../../../cubing/twisty/views/twizzle/url-params";
import { findOrCreateChild, findOrCreateChildWithClass } from "./dom";
import { examples } from "./examples";
import { APP_TITLE } from "./strings";
import { puzzleGroups, supportedPuzzles } from "./supported-puzzles";
import type { SetupToLocation } from "../../../cubing/twisty/model/props/puzzle/state/SetupAnchorProp";
import { URLParamUpdater } from "../../../cubing/twisty/views/twizzle/url-params";
import type { AlgWithIssues } from "../../../cubing/twisty/model/props/puzzle/state/AlgProp";
import { experimentalCountMoves } from "../../../cubing/notation";
import { getStickeringGroup } from "../../../cubing/twisty/model/props/puzzle/display/StickeringProp";
import { FreshListenerManager } from "../../../cubing/twisty/model/props/TwistyProp";
// import { setURLParams } from "./url-params";

// TODO: introduce concepts in `cubing/twisty` for "this is a valid twisty-player value, but not for the current puzzle".
Expand Down Expand Up @@ -266,7 +266,7 @@ class ControlPane {
this.twistyPlayer.experimentalModel.puzzleAlg.addFreshListener(
(algWithIssues: AlgWithIssues) => {
if (algWithIssues.issues.errors.length == 0) {
this.moveCountDisplay.textContent = ` (${experimentalCountMoves(
this.moveCountDisplay.textContent = ` (${experimentalCountMovesETM(
algWithIssues.alg,
)} ETM)`;
} else {
Expand Down

0 comments on commit 1c43df3

Please sign in to comment.