Skip to content

Commit 1544c5b

Browse files
author
suushiemaniac
committed
Add support for piece-orbit exclusive scrambles in 3x3
1 parent eabb69b commit 1544c5b

1 file changed

Lines changed: 81 additions & 7 deletions

File tree

  • src/com/suushiemaniac/cubing/bld/santascramble

src/com/suushiemaniac/cubing/bld/santascramble/Main.java

Lines changed: 81 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.suushiemaniac.cubing.bld.analyze.BldCube;
55
import com.suushiemaniac.cubing.bld.analyze.BldCube.CornerParityMethod;
66
import com.suushiemaniac.cubing.bld.analyze.BldPuzzle;
7+
import com.suushiemaniac.cubing.bld.analyze.ThreeBldCube;
78
import com.suushiemaniac.cubing.bld.filter.BldScramble;
89
import com.suushiemaniac.cubing.bld.filter.condition.BooleanCondition;
910
import com.suushiemaniac.cubing.bld.filter.condition.IntCondition;
@@ -14,6 +15,7 @@
1415
import com.suushiemaniac.io.net.rest.request.Request;
1516
import com.suushiemaniac.io.net.rest.response.Response;
1617
import com.suushiemaniac.lang.json.JSON;
18+
import cs.min2phase.Tools;
1719
import javafx.animation.FadeTransition;
1820
import javafx.animation.SequentialTransition;
1921
import javafx.application.Application;
@@ -36,11 +38,14 @@
3638
import javafx.stage.Stage;
3739
import javafx.util.Duration;
3840
import javafx.util.Pair;
41+
import net.gnehzr.tnoodle.scrambles.Puzzle;
42+
import puzzle.ThreeByThreeCubePuzzle;
3943

4044
import java.io.File;
4145
import java.io.IOException;
4246
import java.util.*;
4347
import java.util.function.Function;
48+
import java.util.function.Supplier;
4449

4550
public 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

Comments
 (0)