0.1.13 • Published 3 years ago

scrambles v0.1.13

Weekly downloads
18
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

scrambles

Puzzle scrambles with the following features:

  • Markov random-state (MRSS) using high-quality randomness, matching WCA standards.
  • Simple and consistent API.
  • Automatic web workers to avoid slowing down web apps.
  • Compatibility with browsers and node (CommonJS or ESM/modules).

Usage

Use as a Promise:

// Using `then`
randomScrambleStringForEvent("333").then((scrambleString) => {
  // Use the result.
});

// Using `await` (in an `async` context)
const scrambleString = await randomScrambleStringForEvent("333");

Full Example

// index.html
<script src="index.js" type="module" defer></script>

<select id="eventID">
  <option value="333" selected>3x3x3</option>
  <option value="444">4x4x4</option>
</select>
<button id="new-scramble">New scramble</button><br>

<div id="scramble-string"></div>
// index.js
import { randomScrambleStringForEvent } from "scrambles";

const eventSelect = document.querySelector("#eventID");
const scrambleStringElem = document.querySelector("#scramble-string");

async function newScramble() {
  scrambleStringElem.textContent += " ⏳";
  const scrambleString = await randomScrambleStringForEvent(eventSelect.value);
  scrambleStringElem.textContent = scrambleString;
}

document.querySelector("#eventID").addEventListener("change", newScramble);
document.querySelector("#new-scramble").addEventListener("click", newScramble);
newScramble(); // Initial scramble

Currently supported events

EventSupportedScramble Filtering
333
222🚧🚧
444🚧
555🚧🚧
666🚧🚧
777🚧🚧
333bf🚧🚧
333fm🚧🚧
333oh
clock
minx
pyram🚧🚧
skewb🚧🚧
sq1🚧🚧
444bf🚧🚧
555bf🚧🚧
333mbf🚧🚧
333ft🚧🚧
fto🚧🚧
kilominx🚧🚧

Acknowledgments

This projects includes code from

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.4

3 years ago

0.0.1

4 years ago