Skip to content

Commit

Permalink
Added a utility method to provide multiple FTO random-state scrambles…
Browse files Browse the repository at this point in the history
…, which is must faster than generating multiple single scrambles.
  • Loading branch information
euphwes committed Jan 11, 2021
1 parent a1719ff commit 0e7c65b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@ In `clockScrambler` module:
### FTO (Face-turning octahedron)
In `ftoScrambler` module:

- `get_random_state_scramble()` random-state scramble (note: this is slow-ish, ~10s per scramble)
- `get_random_state_scramble()` random-state scramble (note: this takes ~10s per scramble)
- `get_multiple_random_state_scrambles(n)` returns a list of `n` random-state scrambles
- `get_random_moves_scramble(n=30)` random-moves scramble of length `n`

If you need multiple random-state scrambles, it's much faster to use `get_multiple_random_state_scrambles` than
calling `get_random_state_scramble` multiple times; the former takes the usual ~10s for the first scramble but then
the remaining scrambles are much faster (less than 1s per scramble). This is due to how the underlying FTO scrambler
generates background data during the first scramble which is used to speed up subsequent scrambles.

### Big cubes
In `bigCubesScrambler` module:

Expand Down
6 changes: 6 additions & 0 deletions pyTwistyScrambler/ftoScrambler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def get_random_state_scramble():
return _FTO_SCRAMBLER.call("generate_random_state_scramble")


def get_multiple_random_state_scrambles(n):
""" Gets `n` random-state scrambles for FTO (face-turning octahedron). """
scrambles = _FTO_SCRAMBLER.call("generate_multiple_random_state_scrambles", n)
return [s.strip() for s in scrambles]


@trim
def get_random_moves_scramble(scramble_length = 30):
""" Returns a random-moves scramble of length `scramble_length` for FTO. """
Expand Down
10 changes: 10 additions & 0 deletions pyTwistyScrambler/js_resources/fto.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,16 @@ function simplify_move_sequence(move_sequence, make_noise=false)
return simplified;
}

function generate_multiple_random_state_scrambles(n)
{
var scrambles = [];
for (var i = 0; i < n; i++) {
scrambles.push(generate_random_state_scramble());
}

return scrambles;
}

function generate_random_state_scramble()
{
return stringify_move_sequence(invert_move_sequence(solve(random_state())), true);
Expand Down

0 comments on commit 0e7c65b

Please sign in to comment.