44import com .suushiemaniac .cubing .bld .analyze .BldCube ;
55import com .suushiemaniac .cubing .bld .analyze .BldCube .CornerParityMethod ;
66import com .suushiemaniac .cubing .bld .analyze .BldPuzzle ;
7+ import com .suushiemaniac .cubing .bld .analyze .ThreeBldCube ;
78import com .suushiemaniac .cubing .bld .filter .BldScramble ;
89import com .suushiemaniac .cubing .bld .filter .condition .BooleanCondition ;
910import com .suushiemaniac .cubing .bld .filter .condition .IntCondition ;
1415import com .suushiemaniac .io .net .rest .request .Request ;
1516import com .suushiemaniac .io .net .rest .response .Response ;
1617import com .suushiemaniac .lang .json .JSON ;
18+ import cs .min2phase .Tools ;
1719import javafx .animation .FadeTransition ;
1820import javafx .animation .SequentialTransition ;
1921import javafx .application .Application ;
3638import javafx .stage .Stage ;
3739import javafx .util .Duration ;
3840import javafx .util .Pair ;
41+ import net .gnehzr .tnoodle .scrambles .Puzzle ;
42+ import puzzle .ThreeByThreeCubePuzzle ;
3943
4044import java .io .File ;
4145import java .io .IOException ;
4246import java .util .*;
4347import java .util .function .Function ;
48+ import java .util .function .Supplier ;
4449
4550public class Main extends Application {
4651 @ Override
@@ -92,13 +97,34 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
9297 Map <PieceType , Map <String , Pair <Spinner <Integer >, Spinner <Integer >>>> masterIntMap = new HashMap <>();
9398 Map <PieceType , Map <String , Pair <CheckBox , CheckBox >>> masterBoolMap = new HashMap <>();
9499 Map <PieceType , HBox > masterLetterPairMap = new HashMap <>();
100+ Map <PieceType , CheckBox > masterScrambleMap = new HashMap <>();
95101
96102 for (PieceType type : puzzle .getAnalyzingPuzzle ().getPieceTypes ()) {
103+ VBox pieceTypeContainer = new VBox (12 );
104+
97105 Map <String , Pair <Spinner <Integer >, Spinner <Integer >>> typeIntMap = new HashMap <>();
98106 Map <String , Pair <CheckBox , CheckBox >> typeBoolMap = new HashMap <>();
99107
100- Label heading = new Label (type .humanName ());
101- heading .setFont (Font .font (heading .getFont ().getFamily (), FontWeight .BOLD , heading .getFont ().getSize ()));
108+ HBox heading = new HBox (8 );
109+ Label headingLabel = new Label (type .humanName ());
110+ headingLabel .setFont (Font .font (headingLabel .getFont ().getFamily (), FontWeight .BOLD , headingLabel .getFont ().getSize ()));
111+ heading .getChildren ().add (headingLabel );
112+
113+ if (puzzle .getAnalyzingPuzzle () instanceof ThreeBldCube ) {
114+ CheckBox scrambleBox = new CheckBox ("Scramble this part?" );
115+ pieceTypeContainer .disableProperty ().bind (scrambleBox .selectedProperty ().not ());
116+
117+ masterScrambleMap .put (type , scrambleBox );
118+
119+ scrambleBox .setSelected (true );
120+ heading .getChildren ().add (scrambleBox );
121+ } else {
122+ CheckBox mockBox = new CheckBox ();
123+ mockBox .setSelected (true );
124+
125+ masterScrambleMap .put (type , mockBox );
126+ }
127+
102128 container .getChildren ().add (heading );
103129
104130 if (puzzle .getAnalyzingPuzzle () instanceof BldCube
@@ -118,7 +144,7 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
118144 HBox .setHgrow (methodLabel , Priority .ALWAYS );
119145 HBox .setHgrow (methods , Priority .ALWAYS );
120146
121- container .getChildren ().add (methodBox );
147+ pieceTypeContainer .getChildren ().add (methodBox );
122148 }
123149
124150 for (String boolProperty : boolProperties ) {
@@ -152,7 +178,7 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
152178 HBox .setHgrow (allowMisOrient , Priority .ALWAYS );
153179 }
154180
155- container .getChildren ().add (line );
181+ pieceTypeContainer .getChildren ().add (line );
156182 }
157183
158184 for (String intProperty : intProperties ) {
@@ -189,7 +215,7 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
189215 HBox .setHgrow (minText , Priority .NEVER );
190216 HBox .setHgrow (maxText , Priority .NEVER );
191217
192- container .getChildren ().add (line );
218+ pieceTypeContainer .getChildren ().add (line );
193219 }
194220 }
195221
@@ -212,11 +238,13 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
212238 lpInput .requestFocus ();
213239 });
214240
215- container .getChildren ().add (letterPairHeader );
241+ pieceTypeContainer .getChildren ().add (letterPairHeader );
216242
217243 masterLetterPairMap .put (type , letterPairIncludes );
218244 masterBoolMap .put (type , typeBoolMap );
219245 masterIntMap .put (type , typeIntMap );
246+
247+ container .getChildren ().add (pieceTypeContainer );
220248 }
221249
222250 // nasty hack for coupled parities
@@ -275,9 +303,55 @@ protected void showSantaPanel(CubicPuzzle puzzle) {
275303
276304 santa .setResultConverter (param -> {
277305 if (param == ButtonType .OK ) {
278- BldScramble scr = new BldScramble (puzzle .getAnalyzingPuzzle (), puzzle .generateScramblingPuzzle ());
306+ Supplier <Puzzle > stdSupplier = puzzle .generateScramblingPuzzle ();
307+ Supplier <Puzzle > scrambleSupplier = () -> {
308+ Puzzle tNoodle = stdSupplier .get ();
309+
310+ if (tNoodle instanceof ThreeByThreeCubePuzzle ) {
311+ boolean scrambleCorners = masterScrambleMap .get (CubicPieceType .CORNER ).isSelected ();
312+ boolean scrambleEdges = masterScrambleMap .get (CubicPieceType .EDGE ).isSelected ();
313+ boolean isRandom = scrambleCorners && scrambleEdges ;
314+
315+ if (!isRandom ) {
316+ ThreeByThreeCubePuzzle castTNoodle = (ThreeByThreeCubePuzzle ) tNoodle ;
317+
318+ byte [] cp = Tools .STATE_SOLVED ;
319+ byte [] co = Tools .STATE_SOLVED ;
320+
321+ if (scrambleCorners ) {
322+ cp = Tools .STATE_RANDOM ;
323+ co = Tools .STATE_RANDOM ;
324+ }
325+
326+ byte [] ep = Tools .STATE_SOLVED ;
327+ byte [] eo = Tools .STATE_SOLVED ;
328+
329+ if (scrambleEdges ) {
330+ ep = Tools .STATE_RANDOM ;
331+ eo = Tools .STATE_RANDOM ;
332+ }
333+
334+ castTNoodle .setCustomConfig (new byte [][]{
335+ cp ,
336+ co ,
337+ ep ,
338+ eo
339+ });
340+
341+ return castTNoodle ;
342+ }
343+ }
344+
345+ return tNoodle ;
346+ };
347+
348+ BldScramble scr = new BldScramble (puzzle .getAnalyzingPuzzle (), scrambleSupplier );
279349
280350 for (PieceType type : puzzle .getAnalyzingPuzzle ().getPieceTypes ()) {
351+ if (!masterScrambleMap .get (type ).isSelected ()) {
352+ continue ;
353+ }
354+
281355 Map <String , Pair <Spinner <Integer >, Spinner <Integer >>> intMap = masterIntMap .get (type );
282356 Map <String , Pair <CheckBox , CheckBox >> boolMap = masterBoolMap .get (type );
283357 HBox letterPairIncludes = masterLetterPairMap .get (type );
0 commit comments