Skip to content

Commit

Permalink
Tidying up before release
Browse files Browse the repository at this point in the history
I set the tests for Variants from GUI which will e explored. All items in variant remain static at the moment
  • Loading branch information
SudokuMonster committed Nov 21, 2019
1 parent 7e91766 commit 3fd16e7
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 14 deletions.
38 changes: 36 additions & 2 deletions diuf/sudoku/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Settings {

public final static int VERSION = 1;
public final static int REVISION = 10;
public final static String SUBREV = ".2";
public final static String SUBREV = ".4";
public final static String releaseDate = "2019-11-14";
public final static String releaseYear = "2019";
public final static String releaseLicence = "Lesser General Public License";
Expand All @@ -38,6 +38,11 @@ public class Settings {
private boolean isShowingCandidateMasks = true;
private boolean isBringBackSE121 = false;//SE121 technique set, order and ratings
private String lookAndFeelClassName = null;

//Variants
private boolean isBlocks = true;
private boolean isX = false;
private boolean isDG = false;

private EnumSet<SolvingTechnique> techniques;

Expand Down Expand Up @@ -147,6 +152,33 @@ public boolean isBringBackSE121() {
return this.isBringBackSE121;
}

public void setBlocks(boolean value) {
this.isBlocks = value;
save();
}

public boolean isBlocks() {
return this.isBlocks;
}

public void setDG(boolean value) {
this.isDG = value;
save();
}

public boolean isDG() {
return this.isDG;
}

public void setX(boolean value) {
this.isX = value;
save();
}

public boolean isX() {
return this.isX;
}

public String getLookAndFeelClassName() {
return lookAndFeelClassName;
}
Expand Down Expand Up @@ -257,7 +289,9 @@ public void save() {
prefs.putBoolean("isAntialiasing", isAntialiasing);
prefs.putBoolean("isShowingCandidates", isShowingCandidates);
prefs.putBoolean("isShowingCandidateMasks", isShowingCandidateMasks);
prefs.putBoolean("isBringBackSE121", isBringBackSE121);
prefs.putBoolean("isBlocks", isBlocks);
prefs.putBoolean("isX", isX);
prefs.putBoolean("isDG", isDG);
if (lookAndFeelClassName != null)
prefs.put("lookAndFeelClassName", lookAndFeelClassName);
try {
Expand Down
6 changes: 6 additions & 0 deletions diuf/sudoku/gui/FourLinks.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
<b>4 strong links</b>: Requires a pattern with 4 single value strong links which can be grouped.
Rating: 5.8-6.1
</body>
</html>
100 changes: 94 additions & 6 deletions diuf/sudoku/gui/SudokuFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public class SudokuFrame extends JFrame implements Asker {
private JRadioButtonMenuItem mitMathMode = null;
private JRadioButtonMenuItem mitChessMode = null;
private JCheckBoxMenuItem mitAntiAliasing = null;
private JMenu variantsMenu = null;
private JCheckBoxMenuItem mitVanilla = null;
private JCheckBoxMenuItem mitLQ = null;
private JCheckBoxMenuItem mitX = null;
private JCheckBoxMenuItem mitDG = null;
private JMenu helpMenu = null;
private JMenuItem mitAbout = null;
private JMenuItem mitGetSmallClue = null;
Expand Down Expand Up @@ -323,6 +328,9 @@ private void initialize() {
Experimental = ".1";
ExSuffix ="New Rating ";
}
if (getInstance().isBringBackSE121()) {
Experimental =" (Original Sudoku Explainer 1.2.1 mode)";
}
this.setTitle(ExSuffix + "Sukaku Explainer " + VERSION + "." + REVISION + SUBREV + Experimental);
JMenuBar menuBar = getJJMenuBar();
setupLookAndFeelMenu();
Expand Down Expand Up @@ -787,6 +795,7 @@ private JMenuBar getJJMenuBar() {
jJMenuBar.add(getEditMenu());
jJMenuBar.add(getToolMenu());
jJMenuBar.add(getOptionsMenu());
jJMenuBar.add(getVariantsMenu());
jJMenuBar.add(getHelpMenu());
}
return jJMenuBar;
Expand Down Expand Up @@ -1375,6 +1384,81 @@ public void itemStateChanged(java.awt.event.ItemEvent e) {
return mitAntiAliasing;
}

private JMenu getVariantsMenu() {
if (variantsMenu == null) {
variantsMenu = new JMenu();
variantsMenu.setText("Variants");
//variantsMenu.setMnemonic(java.awt.event.KeyEvent.VK_H);
variantsMenu.add(getMitVanilla());
variantsMenu.add(getMitLQ());
//getMitShowWelcome().setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
//variantsMenu.addSeparator();
variantsMenu.add(getMitX());
variantsMenu.add(getMitDG());
}
return variantsMenu;
}

private JCheckBoxMenuItem getMitVanilla() {
if (mitVanilla == null) {
mitVanilla = new JCheckBoxMenuItem();
mitVanilla.setText("Vanilla Sudoku");
mitVanilla.setSelected(true);
mitVanilla.setToolTipText("Vanilla Sudoku with Row, Columns and Blocks");
mitVanilla.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
mitVanilla.setSelected(true);
}
});
}
return mitVanilla;
}

private JCheckBoxMenuItem getMitLQ() {
if (mitLQ == null) {
mitLQ = new JCheckBoxMenuItem();
mitLQ.setText("Latin Square (LQ)");
mitLQ.setSelected(false);
mitLQ.setToolTipText("Latin Square with Row and columns only. No Blocks");
mitLQ.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
mitLQ.setSelected(false);
}
});
}
return mitLQ;
}

private JCheckBoxMenuItem getMitX() {
if (mitX == null) {
mitX = new JCheckBoxMenuItem();
mitX.setText("X main diagonals");
mitX.setSelected(false);
mitX.setToolTipText("Adds the 2 main diagonals (X) as constraints");
mitX.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
mitX.setSelected(false);
}
});
}
return mitX;
}

private JCheckBoxMenuItem getMitDG() {
if (mitDG == null) {
mitDG = new JCheckBoxMenuItem();
mitDG.setText("DG");
mitDG.setSelected(false);
mitDG.setToolTipText("Add 9 disjoint groups");
mitDG.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
mitDG.setSelected(false);
}
});
}
return mitDG;
}

private JMenu getHelpMenu() {
if (helpMenu == null) {
helpMenu = new JMenu();
Expand Down Expand Up @@ -1544,10 +1628,12 @@ public void itemStateChanged(java.awt.event.ItemEvent e) {
mitBringBackSE121.setSelected(false);
Settings.getInstance().setlkSudokuBUG(true);
Settings.getInstance().setlkSudokuURUL(true);
engine.clearGrid();
engine.clearHints();
}
repaint();
engine.clearGrid();
engine.clearHints();
initialize();
repaintViews();
showWelcomeText();
}
});
}
Expand All @@ -1574,10 +1660,12 @@ public void itemStateChanged(java.awt.event.ItemEvent e) {
mitNewRevisedRatings.setSelected(false);
Settings.getInstance().setlkSudokuBUG(false);
Settings.getInstance().setlkSudokuURUL(false);
engine.clearGrid();
engine.clearHints();
}
repaint();
engine.clearGrid();
engine.clearHints();
initialize();
repaintViews();
showWelcomeText();
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion diuf/sudoku/gui/ThreeStrongLinks.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html>
<body>
<b>3 strong links</b>: Requires a fish with 3 strong links (101 or 102 formation)
<b>3 strong links</b>: Requires a pattern with 3 single value strong links (101 or 102 formation).
Rating: 5.5-5.6
</body>
</html>
14 changes: 9 additions & 5 deletions diuf/sudoku/solver/Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,19 @@ public Solver(Grid grid) {
addIfWorth(SolvingTechnique.Swordfish, indirectHintProducers, new Fisherman(3));
addIfWorth(SolvingTechnique.XYWing, indirectHintProducers, new XYWing(false));
addIfWorth(SolvingTechnique.XYZWing, indirectHintProducers, new XYWing(true));
// addIfWorth(SolvingTechnique.WWing, indirectHintProducers, new WWing());
// addIfWorth(SolvingTechnique.WWing, indirectHintProducers, new WWing());
addIfWorth(SolvingTechnique.UniqueLoop, indirectHintProducers, new UniqueLoops());
addIfWorth(SolvingTechnique.NakedQuad, indirectHintProducers, new NakedSet(4));
addIfWorth(SolvingTechnique.HiddenQuad, indirectHintProducers, new HiddenSet(4, false));
addIfWorth(SolvingTechnique.Jellyfish, indirectHintProducers, new Fisherman(4));
addIfWorth(SolvingTechnique.WXYZWing, indirectHintProducers, new WXYZWing());
addIfWorth(SolvingTechnique.HiddenQuad, indirectHintProducers, new HiddenSet(4, false));
addIfWorth(SolvingTechnique.ThreeStrongLinks, indirectHintProducers, new StrongLinks(3));
addIfWorth(SolvingTechnique.WXYZWing, indirectHintProducers, new WXYZWing());
addIfWorth(SolvingTechnique.BivalueUniversalGrave, indirectHintProducers, new BivalueUniversalGrave());
addIfWorth(SolvingTechnique.VWXYZWing, indirectHintProducers, new VWXYZWing());
addIfWorth(SolvingTechnique.AlignedPairExclusion, indirectHintProducers, new AlignedPairExclusion());
addIfWorth(SolvingTechnique.FourStrongLinks, indirectHintProducers, new StrongLinks(4));
addIfWorth(SolvingTechnique.VWXYZWing, indirectHintProducers, new VWXYZWing());
addIfWorth(SolvingTechnique.AlignedPairExclusion, indirectHintProducers, new AlignedPairExclusion());
addIfWorth(SolvingTechnique.FiveStrongLinks, indirectHintProducers, new StrongLinks(5));
addIfWorth(SolvingTechnique.SixStrongLinks, indirectHintProducers, new StrongLinks(6));
chainingHintProducers = new ArrayList<IndirectHintProducer>();
addIfWorth(SolvingTechnique.ForcingChainCycle, chainingHintProducers, new Chaining(false, false, false, 0, false, 0));
addIfWorth(SolvingTechnique.AlignedTripletExclusion, chainingHintProducers, new AlignedExclusion(3));
Expand Down

0 comments on commit 3fd16e7

Please sign in to comment.