diff --git a/diuf/sudoku/Settings.java b/diuf/sudoku/Settings.java index b576a8f..44a764e 100644 --- a/diuf/sudoku/Settings.java +++ b/diuf/sudoku/Settings.java @@ -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"; @@ -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 techniques; @@ -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; } @@ -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 { diff --git a/diuf/sudoku/gui/FourLinks.html b/diuf/sudoku/gui/FourLinks.html new file mode 100644 index 0000000..442e735 --- /dev/null +++ b/diuf/sudoku/gui/FourLinks.html @@ -0,0 +1,6 @@ + + + 4 strong links: Requires a pattern with 4 single value strong links which can be grouped. + Rating: 5.8-6.1 + + \ No newline at end of file diff --git a/diuf/sudoku/gui/SudokuFrame.java b/diuf/sudoku/gui/SudokuFrame.java index 4c0182b..a0ee94f 100644 --- a/diuf/sudoku/gui/SudokuFrame.java +++ b/diuf/sudoku/gui/SudokuFrame.java @@ -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; @@ -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(); @@ -787,6 +795,7 @@ private JMenuBar getJJMenuBar() { jJMenuBar.add(getEditMenu()); jJMenuBar.add(getToolMenu()); jJMenuBar.add(getOptionsMenu()); + jJMenuBar.add(getVariantsMenu()); jJMenuBar.add(getHelpMenu()); } return jJMenuBar; @@ -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(); @@ -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(); } }); } @@ -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(); } }); } diff --git a/diuf/sudoku/gui/ThreeStrongLinks.html b/diuf/sudoku/gui/ThreeStrongLinks.html index c0724dc..82746fc 100644 --- a/diuf/sudoku/gui/ThreeStrongLinks.html +++ b/diuf/sudoku/gui/ThreeStrongLinks.html @@ -1,6 +1,6 @@ - 3 strong links: Requires a fish with 3 strong links (101 or 102 formation) + 3 strong links: Requires a pattern with 3 single value strong links (101 or 102 formation). Rating: 5.5-5.6 \ No newline at end of file diff --git a/diuf/sudoku/solver/Solver.java b/diuf/sudoku/solver/Solver.java index 1563eb3..9bffc1f 100644 --- a/diuf/sudoku/solver/Solver.java +++ b/diuf/sudoku/solver/Solver.java @@ -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(); addIfWorth(SolvingTechnique.ForcingChainCycle, chainingHintProducers, new Chaining(false, false, false, 0, false, 0)); addIfWorth(SolvingTechnique.AlignedTripletExclusion, chainingHintProducers, new AlignedExclusion(3));