# Looking for advice / resources for a custom Square-1 scrambler



## sp3ctum (Aug 1, 2017)

Hello!
I'm practicing my Square-1 and writing a personal trainer program for it: https://github.com/sp3ctum/squanmate

One of the main things I'm currently learning is cubeshape parity. This is a method of defining the parity of the puzzle in the 15 second inspection time, and then choosing an algorithm for the specific starting shape case to force the parity to be even at cubeshape. This is all great, and my app is pretty helpful in porting algorithms to my own google sheets document: https://docs.google.com/spreadsheet...mmc-A5UBpNPvsEOb7eWaEtIFo/edit#gid=1657302822

But now I'd like to make a cubeshape parity trainer. Here's some idea how I'd like to make it work:

let the user choose a number of the 92-ish possible shape cases
show a scramble that ends up in one of these cases
(let the user solve it)
I've looked into how existing Square-1 random state scramblers are implemented, and I have to say I'm really having trouble reusing existing code. It seems the performance of these current generators is very good, but the code is very hard to understand for me. Of course it would be trivial to generate a scramble for any shape case, but in my case I specifically want to limit the available cases...

Would someone be so kind as to give me their thoughts on how it would be best to proceed with this problem? I don't mind investing some research and time into this, but I'd also like to invest my time wisely.

Thanks in advance.


----------



## bobthegiraffemonkey (Aug 1, 2017)

sp3ctum said:


> 92-ish possible shape cases


90, including cubeshape itself. There are:
-10 layer shapes with 4 edges, which gives 55 cases (the 10th triangle number)
-3 layer shapes with 2 edges and 10 with 6, which gives 30 cases
-5 cases with 8 edges on one layer
55+30+5=90

I'll be keeping an eye on this thread as I'd probably use a CSP trainer to get better at the cases I find difficult.


----------



## tx789 (Aug 1, 2017)

Having a OBL, EP and PBL trainer would be useful to. The latter would be much more useful. With the option to not have partiy for PBL. (EO too but that would only be useful to practise the EO CP transition).


----------



## sp3ctum (Aug 5, 2017)

Thanks for the responses. It's great to see others think this would be useful. I can post my progress regarding this feature in this thread.

My current approach to generating scrambles with constraints for different cases is this:

generate a random puzzle (piece ordering) that fulfills a constraint - for example an ordering for a shield square case
determine the sequence of moves that solves this scramble. To do this, I managed to compile and modify Jaap's Square-1 solver program, written in C++ a long time ago, into javascript so it runs in the browser.
Reverse the solve algorithm. This actually makes the solve into a scramble sequence, in this example from a solved puzzle to the randomly created shield square case
I believe this is the official method of getting scramble sequences for many WCA puzzles too. I'm not really looking for extremely good randomness, but it's still funny to notice that this method serves my need very well.

So far I have the solver working, so the most complicated part of this algorithm should be implemented.

Oh, and regarding different kinds of constraints for this trainer: I think all the ones that have been mentioned should be quite simple to implement. 
I'm going to focus on cubeshape parity, as that is the one I care about the most. This could include:

cubeshape parity
orient both layers
edge permutation
(what is PBL?) permute both layers? I use the Lin method so I know 11 algorithms only


----------



## tx789 (Aug 5, 2017)

sp3ctum said:


> cubeshape parity
> orient both layers
> edge permutation
> (what is PBL?) permute both layers? I use the Lin method so I know 11 algorithms only



Yes that is what PBL is. Most people would find it useful for the CP EP transition. I also think it is important to have the ability to have PBL and Ep cases with and without parity.


----------



## sp3ctum (Aug 9, 2017)

The cubeshape parity trainer is up!
You get to select which combinations of shapes you want to train, and random scrambles leading to those are generated.
The UI is pretty klunky (it makes me laugh) because I wanted to release something.

If you have the time, please let me know what you think.


----------



## bobthegiraffemonkey (Aug 9, 2017)

sp3ctum said:


> The cubeshape parity trainer is up!
> You get to select which combinations of shapes you want to train, and random scrambles leading to those are generated.
> The UI is pretty klunky (it makes me laugh) because I wanted to release something.
> 
> If you have the time, please let me know what you think.


Good start, but a few things I want to point out:

-The list of cases is pretty horrible to look at and find stuff in.
-List of shapes says 11 4/4 shapes, there are 10
-Illegal AUFs at end of scramble sometimes, such as (0,-4)/ (3,0)/ (1,-2)/ (2,-4)/ (3,0)/ (6,-3)/ (4,-2)/ (0,-4)/ (-3,-3)/ (-1,-2)/ (5,6)
-New scramble button gives a new image very quickly and the scramble much slower. A few times I nearly started scrambling before it updated because I'm used to only being able to see a scramble once the next one is ready to be shown.

Bookmarked, looking forward to improved versions!


----------



## sp3ctum (Aug 10, 2017)

Thanks for the feedback! Really appreciate your thoughts.



bobthegiraffemonkey said:


> -Illegal AUFs at end of scramble sometimes, such as (0,-4)/ (3,0)/ (1,-2)/ (2,-4)/ (3,0)/ (6,-3)/ (4,-2)/ (0,-4)/ (-3,-3)/ (-1,-2)/ (5,6)


This is pretty complex, so let me explain my reasoning in how the scrambles are generated:

pick a top and bottom layer randomly from the horrible looking checkboxes the user has chosen
place the pieces randomly in both layers
rotate both layers randomly (so they aren't in the same position each time).
..more things
The scramble you gave for example, it performs step 3 in the last position of the scramble sequence, it's (5,6). Do you know if scrambles should always end in positions that are "sliceable", by which I mean you can do a / move at that position?



bobthegiraffemonkey said:


> -New scramble button gives a new image very quickly and the scramble much slower. A few times I nearly started scrambling before it updated because I'm used to only being able to see a scramble once the next one is ready to be shown.


This is a really good observation. I'll make it more obvious that the scramble is being generated.


----
edit: I looked up https://www.worldcubeassociation.org/regulations/#article-4-scrambling to see if there are regulations about having the layers in a sliceable position. I found nothing on this.

edit 2:
I fixed some minor bugs you reported. In order to not pollute this forum with updates, I recommend you follow the project's changelog and issue tracker.

Oh, make sure you bookmark https://github.com/sp3ctum/squanmate and always use the link in the readme to open the app separately. I've had issues with after a new release, where the new release hasn't loaded properly because the old one had been opened recently. There is now a link to open the app that is unique to each specific release to try and fix this (the newest will always be in the readme).


----------

