From 7e0b43366ef866f21e159b3ba14afadb14920c54 Mon Sep 17 00:00:00 2001 From: SudokuMonster Date: Sat, 21 Dec 2019 10:54:24 +0000 Subject: [PATCH] Bug fixes, Comments and clear warnings --- diuf/sudoku/Settings.java | 18 +++++++++--------- diuf/sudoku/gui/SudokuFrame.java | 1 + diuf/sudoku/gui/SudokuPanel.java | 3 ++- diuf/sudoku/solver/rules/NakedSetGen.java | 5 +++-- diuf/sudoku/test/serate.java | 12 +++++++----- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/diuf/sudoku/Settings.java b/diuf/sudoku/Settings.java index 5d758ba..2b208f3 100644 --- a/diuf/sudoku/Settings.java +++ b/diuf/sudoku/Settings.java @@ -18,8 +18,8 @@ public class Settings { public final static int VERSION = 1; public final static int REVISION = 14; - public final static String SUBREV = ".8"; - public final static String releaseDate = "2019-12-18"; + public final static String SUBREV = ".11"; + public final static String releaseDate = "2019-12-21"; public final static String releaseYear = "2019"; public final static String releaseLicence = "Lesser General Public License"; public final static String releaseLicenceMini = "LGPL"; @@ -298,7 +298,7 @@ public void toggleVariants() { public void setBlocks(boolean isBlocks) { this.isBlocks = isBlocks; - toggleVariants(); + toggleVariants();; save(); } @@ -308,7 +308,7 @@ public boolean isBlocks() { public void setDG(boolean value) { this.isDG = value; - toggleVariants(); + toggleVariants();; save(); } @@ -318,7 +318,7 @@ public boolean isDG() { public void setX(boolean value) { this.isX = value; - toggleVariants(); + toggleVariants();; save(); } @@ -328,7 +328,7 @@ public boolean isX() { public void setWindows(boolean value) { this.isWindows = value; - toggleVariants(); + toggleVariants();; save(); } @@ -338,7 +338,7 @@ public boolean isWindows() { public void setGirandola(boolean value) { this.isGirandola = value; - toggleVariants(); + toggleVariants();; save(); } @@ -348,7 +348,7 @@ public boolean isGirandola() { public void setCD(boolean value) { this.isCD = value; - toggleVariants(); + toggleVariants();; save(); } @@ -358,7 +358,7 @@ public boolean isCD() { public void setAsterisk(boolean value) { this.isAsterisk = value; - toggleVariants(); + toggleVariants();; save(); } diff --git a/diuf/sudoku/gui/SudokuFrame.java b/diuf/sudoku/gui/SudokuFrame.java index 24035ae..f8e962f 100644 --- a/diuf/sudoku/gui/SudokuFrame.java +++ b/diuf/sudoku/gui/SudokuFrame.java @@ -257,6 +257,7 @@ public void setCurrentHint(Grid grid, Hint hint, boolean isApplyEnabled) { } else { getHintDetailArea().setText(null); getSudokuPanel().setBlueRegions(); + //SudokuMonster: setHighlightedCells is an alternative to yellow cell backgrounds getSelectedCells() getSudokuPanel().setHighlightedCells(null); getSudokuPanel().setLinks(null); viewCount = 1; diff --git a/diuf/sudoku/gui/SudokuPanel.java b/diuf/sudoku/gui/SudokuPanel.java index 4ee9681..5f0a77a 100644 --- a/diuf/sudoku/gui/SudokuPanel.java +++ b/diuf/sudoku/gui/SudokuPanel.java @@ -48,6 +48,7 @@ public class SudokuPanel extends JPanel { private Collection greenCells; private Collection redCells; private Grid.Region[] blueRegions; +//SudokuMonster: Modification to yellow background cells getSelectedCells() private Cell[] highlightedCells; private Collection links; @@ -337,7 +338,7 @@ public void setBluePotentials(Map bluePotentials) { public void setBlueRegions(Grid.Region... regions) { this.blueRegions = regions; } - +//SudokuMonster: Modification to yellow background cells getSelectedCells() public void setHighlightedCells(Cell[] cells) { this.highlightedCells = cells; } diff --git a/diuf/sudoku/solver/rules/NakedSetGen.java b/diuf/sudoku/solver/rules/NakedSetGen.java index 030753f..ffdfcc4 100644 --- a/diuf/sudoku/solver/rules/NakedSetGen.java +++ b/diuf/sudoku/solver/rules/NakedSetGen.java @@ -107,7 +107,8 @@ private IndirectHint createValueUniquenessGenHint(Grid grid, Grid.Region region, } // Build removable potentials Map removablePotentials = new HashMap(); - int eliminationsTotal = 0; + //SudokuMonster: eliminationsTotal can be enabled to sort hints + //int eliminationsTotal = 0; for(int i = commonPotentialValues.nextSetBit(0); i >= 0; i = commonPotentialValues.nextSetBit(i + 1)) { CellSet Victims = null; for (Cell cell : cells) @@ -118,7 +119,7 @@ private IndirectHint createValueUniquenessGenHint(Grid grid, Grid.Region region, Victims.retainAll(cell.getVisibleCells()); for (Cell cell : Victims) if (grid.hasCellPotentialValue(cell.getIndex(), i)) { - eliminationsTotal++; + //eliminationsTotal++; if (removablePotentials.containsKey(cell)) removablePotentials.get(cell).set(i); else diff --git a/diuf/sudoku/test/serate.java b/diuf/sudoku/test/serate.java index bd4c21f..7550602 100644 --- a/diuf/sudoku/test/serate.java +++ b/diuf/sudoku/test/serate.java @@ -227,7 +227,7 @@ private static String isItExperimental() { * 1 for use */ private static boolean setTechniques(String techniques, boolean showArguments) { - EnumSet allTechniques = EnumSet.allOf(SolvingTechnique.class); + EnumSet allTechniques = EnumSet.allOf(SolvingTechnique.class); try { EnumSet useTechniques = EnumSet.noneOf(SolvingTechnique.class); Iterator iter = allTechniques.iterator(); @@ -314,7 +314,8 @@ public static void main(String[] args) { boolean isX = false; //X (Main diagonal and Anti diagonal groups) are by default disabled. boolean isGirandola = false; //Girandola is by default disabled. boolean isAsterisk = false; //Asterisk is by default disabled. - boolean isCD = false; //Center Dot is by default disabled. + boolean isCD = false; //Center Dot is by default disabled. + boolean isTechs = false; //This checks if --techs has been used. char want = 0; int arg; //long t; //not used anymore @@ -560,7 +561,7 @@ else if (++arg < args.length) { break; //@SudokuMonster: (lkSudoku) case '~': - setTechniques(v, showArguments); + isTechs = setTechniques(v, showArguments); break; default: usage(a, 0); @@ -599,8 +600,9 @@ else if (++arg < args.length) { writer = new PrintWriter(writer1); } formatter = new Formatter(writer, formatStart, formatAfter, formatBefore, format); - //@SudokuMonster: The following is to target the static visibleCells in case there are variants - Grid.changeVisibleCells(); + //@SudokuMonster: The following is to default to the default set of techniques even if variants + if (!isTechs) + Settings.getInstance().Settings_Variants(); //loop over input puzzles for (;;) { if (reader != null) {