diff --git a/README.md b/README.md index 3b278eb..3118e94 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/pyTwistyScrambler/ftoScrambler.py b/pyTwistyScrambler/ftoScrambler.py index 3c8be88..da9b66b 100644 --- a/pyTwistyScrambler/ftoScrambler.py +++ b/pyTwistyScrambler/ftoScrambler.py @@ -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. """ diff --git a/pyTwistyScrambler/js_resources/fto.js b/pyTwistyScrambler/js_resources/fto.js index c298a11..01c5c66 100644 --- a/pyTwistyScrambler/js_resources/fto.js +++ b/pyTwistyScrambler/js_resources/fto.js @@ -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);