-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Compose Scrambles #77
Comments
If you are using JavaScript or Rust, then |
Maybe, but it's written in TypeScript and I never learned it. I mainly code in C/C++. Obviously, I'm trying to chain together executions of TWSearch. |
Thanks, that's very useful to know! We do indeed have support for this but currently only for 3x3x3: import { Alg } from "cubing/alg";
import {
ExperimentalCommonMetric,
experimentalCountMetricMoves,
} from "cubing/notation";
import { cube3x3x3 } from "cubing/puzzles";
console.log(
experimentalCountMetricMoves(
cube3x3x3,
ExperimentalCommonMetric.OuterBlockTurnMetric,
new Alg("[2U, r' D r]"),
),
); https://codepen.io/lgarron/pen/RNbgmYJ?editors=1010 I've filed cubing/cubing.js#350 to keep track of this. |
For what it's worth, we're working on phase composition in the Rust code, and I want a good API for this. If you would like to describe any details about your use case, they'd be helpful! |
I was just going to have a Bash script that made iterative calls to twsearch with different definition files and construct intermediate scramables between each call. It works fine when the initial scramble is an alg, but when it is a state, such as for implementing a random-state solver (leading to a random-state scramble generator), then it's not clear how to tack on a partial solution alg to the initial state. I ended up spending a few hours today and coding up an entire TWS definition file parser that produces data structures making it easy to apply moves to a puzzle state. But it's probably only 1/3 of the way done... I need to use a portion of it to parse a SCR file, then execute the moves on to the state, then print the new state. |
There would have to be a way to specify an accending series of puzzle definitions somehow. For example, on of my intermediate CH2 definitions has TIPs and WINGs omitted, just CORNERs and MIDGEs, but I partition the 24 MIDGEs into three sets of 8 for each of M/E/S. The original, full definition file has tip turn moves that are no-ops at this stage, and I need a way to handle stuff like that gracefully. Currently, TWSearch errors-out when reading an alg that includes such moves. |
Sounds like you could use twsearch/src/rs/scramble/puzzles/mask_pattern.rs Lines 7 to 10 in 7c1df36
Would you be interested in doing a video call pairing session some time to see what we can apply to your solver? Alternatively, do you already have definitions for all the intermediate states? |
I have never learned Rust. I probable should tho. And for doing that sort of masking, I wrote a small Bash script:
The last line removes the Moves which are rendered null. And I append something useful to the puzzle "Name" field. |
Note that twsearch can "apply algs to states" if you make a .tws file with
the source state as the
"solved" position and then use the --showpositions argument. I'm not
saying this is convenient, but
it might be useful to check things.
The twsearch program is not really set up yet for modular phased solves;
there are too many globals
and such. I have been hoping to fix this for some time but it hasn't
happened. Likely someone a
better coder than I will eventually help with this or code a replacement.
I have hopes the ongoing
Rust project might be that, but it's not there yet.
…-tom
On Thu, Dec 26, 2024 at 9:33 PM DougCube ***@***.***> wrote:
I have never learned Rust. I probable should tho.
I just finished coding a program to do what I need in applying algs to
states.
I've done a fair bit of validation on it now and might change the github
for it to public.
And for doing that sort of masking, I wrote a small Bash script:
if [ "$#" -lt 1 ]; then
echo "ERROR: the syntax is '$0 <tws file> [set1 to remove] [set2 to remove]...'!" >&2
exit 1
fi
file="$1"; shift
temp1="/tmp/def_omit_sets1.out"
temp2="/tmp/def_omit_sets2.out"
# remove comments and leading empty lines
sed '/#/d;/./,$!d' "$file" > "$temp1"
for x in "$@"; do
sed -r 's/^Name ([^[:space:]]+)/Name \1_NO_'"$x"'/;/^Set '"$x"'/d' "$temp1" > "$temp2"
awk '/^'"$x"'/{f=1; next} f && !/^[0-9]/{f=0} !f' "$temp2" > "$temp1"
done
sed -r -z 's/Move [^[:space:]]+\nEnd\n\n//g' "$temp1"
The last line removes the Moves which are rendered null. And I append
something useful to the puzzle "Name" field.
—
Reply to this email directly, view it on GitHub
<#77 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMOLS5USYDHRKTMSM3B6D32HTRBZAVCNFSM6AAAAABUEN2EQGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRTGMZTMNRRHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
That would have been good to know a few days ago. But I immediately started coding up my own *.tws and *.scr file parser and got it working. Composing the permutations forwards and backwards was obvious, but I couldn't figure out how to compose the orientations with it until I wrote tiny testcases and ran a bunch of It took me 290 lines of C code and is very robust, but can only handle moves like |
I'm revisiting a project I was working on 13 months ago, and got a full CH2 solver down to 14 stages with a lot of intermediate definition files created -- way more than 14 while trying different options. My first test scramble was a random-move scramble from the Steven's python scramble generator. I could keep appending to the scramble manually. But the goal was always to generate a random-state to solve. I incorrectly assumed that TWSearch was capable of generating random-state scrambles, but now that I looked into it, it's random 500-move, and without a way to specify the length. TWSearch should probably implement a random-state generator. When I got a multi-stage procedure working, I switched to using a state scramble input, but faced this major hurdle of composing alg with initial state and appearently gave up back then. I've picked it up after working on other things like an FTO solver. But recently, it's occured to me that the first stage I have it running takes far too long and am suspecting a performance issue in TWSearch itself when dealing with the large set of canonical moves and perhaps not pruning agressively enough. A bit off topic: I now have a nifty FTO solver that converts input scramble to wide moves, then runs TWSearch with only |
It would be good to have a way to compose scrambles (of different formats):
Number 2 is the most useful in the flow of creating multi-stage solvers that start from a state instead of an alg. (Which is needed in random-state scramble generators, you generate a random state, solve it, and the inverse of the solve alg is the scramble alg.) Number 1 seems to be the most basic to include since
--showpositions
has a mechanism to convert algs to states anyways. Thus, having a way to accomplish 1 can give 2, 3, and 4 nearly for free. I can't think of a situation requiring number 3, but might as well. Number 5 is trivial, but listed for completeness sake.The text was updated successfully, but these errors were encountered: