diff --git a/diuf/sudoku/Cell.java b/diuf/sudoku/Cell.java index d29dffe..95640d9 100644 --- a/diuf/sudoku/Cell.java +++ b/diuf/sudoku/Cell.java @@ -10,6 +10,7 @@ public class Cell { private final int index; + private boolean isGiven; /** * Create a new cell @@ -21,6 +22,18 @@ public Cell(int index) { this.index = index; } + public void setGiven() { + this.isGiven = true; + } + + public void resetGiven() { + this.isGiven = false; + } + + public boolean isGiven() { + return this.isGiven; + } + /** * Get the x coordinate of this cell. * 0 = leftmost, 8 = rightmost diff --git a/diuf/sudoku/Grid.java b/diuf/sudoku/Grid.java index de05b27..39cddc1 100644 --- a/diuf/sudoku/Grid.java +++ b/diuf/sudoku/Grid.java @@ -31,6 +31,7 @@ public class Grid { * Cell potential values of the grid, bit 0 is unused. */ private BitSet[] cellPotentialValues = new BitSet[81]; + private boolean[] isGiven = new boolean[81]; // //cache for Region.getPotentialPositions(value) // private valueCells valueCellsCache = new valueCells(); @@ -372,6 +373,23 @@ public static Grid.Region getRegionAt(int regionTypeIndex, int cellIndex) { //=== Non-static methods ============== + /** + * Is the cell a given or not + * @param index the cell index [0..80] + */ + + public void setGiven(int index) { + this.isGiven[index] = true; + } + + public void resetGiven(int index) { + this.isGiven[index] = false; + } + + public boolean isGiven(int index) { + return this.isGiven[index]; + } + /** * Set the value of a cell * @param x the horizontal coordinate of the cell @@ -380,6 +398,7 @@ public static Grid.Region getRegionAt(int regionTypeIndex, int cellIndex) { */ public void setCellValue(int x, int y, int value) { cellValues[y * 9 + x] = value; + setGiven(y * 9 + x); } /** @@ -389,6 +408,7 @@ public void setCellValue(int x, int y, int value) { */ public void setCellValue(int index, int value) { cellValues[index] = value; + //setGiven(index); } /** @@ -535,6 +555,10 @@ public void copyTo(Grid other) { for (int i = 0; i < 81; i++) { other.setCellValue(i, this.cellValues[i]); other.setCellPotentialValues(i, cellPotentialValues[i]); + if (this.isGiven(i)) + other.setGiven(i); + else + other.resetGiven(i); } // //clone the cache as well // for(int regionType = 0; regionType < 3; regionType++) { @@ -755,7 +779,7 @@ public void adjustPencilmarks() { } } if(isnakedsingle) { - setCellValue(i, singleclue); + setCellValue(i % 9, i / 9, singleclue); clearCellPotentialValues(i); } } diff --git a/diuf/sudoku/Settings.java b/diuf/sudoku/Settings.java index 7abdf81..b576a8f 100644 --- a/diuf/sudoku/Settings.java +++ b/diuf/sudoku/Settings.java @@ -17,8 +17,8 @@ public class Settings { public final static int VERSION = 1; - public final static int REVISION = 9; - public final static String SUBREV = ".4"; + public final static int REVISION = 10; + public final static String SUBREV = ".2"; public final static String releaseDate = "2019-11-14"; public final static String releaseYear = "2019"; public final static String releaseLicence = "Lesser General Public License"; diff --git a/diuf/sudoku/gui/SudokuPanel.java b/diuf/sudoku/gui/SudokuPanel.java index 243b9bd..ce9767e 100644 --- a/diuf/sudoku/gui/SudokuPanel.java +++ b/diuf/sudoku/gui/SudokuPanel.java @@ -33,7 +33,7 @@ public class SudokuPanel extends JPanel { private int LEGEND_GAP_SIZE = 42; private int CELL_PAD = (CELL_OUTER_SIZE - CELL_INNER_SIZE) / 2; private int GRID_SIZE = CELL_OUTER_SIZE * 9; - private String FONT_NAME = "Verdana"; + private String FONT_NAME = "Arial Black"; private int FONT_SIZE_SMALL = 12; private int FONT_SIZE_BIG = 36; private int FONT_SIZE_LEGEND = 24; @@ -76,9 +76,9 @@ public SudokuPanel(SudokuFrame parent) { rescale(); initialize(); super.setOpaque(false); - smallFont = new Font(FONT_NAME, Font.BOLD, FONT_SIZE_SMALL); - bigFont = new Font(FONT_NAME, Font.BOLD, FONT_SIZE_BIG); - legendFont = new Font(FONT_NAME, Font.BOLD, FONT_SIZE_LEGEND); + smallFont = new Font(FONT_NAME, Font.PLAIN, FONT_SIZE_SMALL); + bigFont = new Font(FONT_NAME, Font.PLAIN, FONT_SIZE_BIG); + legendFont = new Font(FONT_NAME, Font.PLAIN, FONT_SIZE_LEGEND); } private void rescale() { @@ -482,7 +482,9 @@ else if (cell == focusedCell) } private void initValueColor(Graphics g, Cell cell, int x, int y) { - Color col = Color.black; + //Modified on request from rjamil using what 1to9only implemented in his 16x16 version but changed to accomodate dobrichev Grid & Cell changes + //Color col = Color.black; + Color col = grid.isGiven(y * 9 + x) ? Color.black : Color.blue; if (null != selectedCell && grid.getCellValue(selectedCell.getX(), selectedCell.getY()) == grid.getCellValue(x, y)) col = sameCellValueColor; if (cell == selectedCell) diff --git a/diuf/sudoku/solver/Solver.java b/diuf/sudoku/solver/Solver.java index b8d031a..1563eb3 100644 --- a/diuf/sudoku/solver/Solver.java +++ b/diuf/sudoku/solver/Solver.java @@ -211,8 +211,6 @@ public Solver(Grid grid) { addIfWorth(SolvingTechnique.HiddenQuad, indirectHintProducers, new HiddenSet(4, false)); addIfWorth(SolvingTechnique.ThreeStrongLinks, indirectHintProducers, new StrongLinks(3)); addIfWorth(SolvingTechnique.WXYZWing, indirectHintProducers, new WXYZWing()); - //addIfWorth(SolvingTechnique.VWXYZWing4, indirectHintProducers, new VWXYZWing(true)); - //addIfWorth(SolvingTechnique.VWXYZWing5, indirectHintProducers, new VWXYZWing(false)); addIfWorth(SolvingTechnique.BivalueUniversalGrave, indirectHintProducers, new BivalueUniversalGrave()); addIfWorth(SolvingTechnique.FourStrongLinks, indirectHintProducers, new StrongLinks(4)); addIfWorth(SolvingTechnique.VWXYZWing, indirectHintProducers, new VWXYZWing()); diff --git a/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html b/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html index a4bd44d..99a711f 100644 --- a/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html +++ b/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html @@ -19,11 +19,11 @@
- This technique is part of more genralized technique called X- chains which in itself + This technique is part of more generalized technique called X- chains which in itself is part of more generalized technique called Alternating Inference Chains (AIC).
- This technique uses logic closely realted to Finned {10} technique logic. + This technique uses logic closely related to {10} technique logic.
The grouped strong link when inferred from cells in a block that are diff --git a/diuf/sudoku/solver/rules/StrongLinksHint.html b/diuf/sudoku/solver/rules/StrongLinksHint.html index d5c8e33..0f78497 100644 --- a/diuf/sudoku/solver/rules/StrongLinksHint.html +++ b/diuf/sudoku/solver/rules/StrongLinksHint.html @@ -13,7 +13,7 @@
- This technique is similar to a 2x2x2 Finned {10} technique logic, Coloring + This technique is closely related to {10} technique logic, Coloring technique or L1-Wing technique. It is a subcategory of X-Chains group of techniques which is in itself a subgroup of Alternating Inference Chains (AIC) group of techniques.
diff --git a/diuf/sudoku/solver/rules/StrongLinksHint.java b/diuf/sudoku/solver/rules/StrongLinksHint.java index cd2b92e..8a16949 100644 --- a/diuf/sudoku/solver/rules/StrongLinksHint.java +++ b/diuf/sudoku/solver/rules/StrongLinksHint.java @@ -165,10 +165,17 @@ public String toString() { @Override public String toHtml(Grid grid) { String result; - if (groupedLinks() > 0) + String fishName = getFishName(linksNumber); + if (groupedLinks() > 0) { result = HtmlLoader.loadHtml(this, "GroupedStrongLinksHint.html"); - else + fishName = "Finned " + fishName; + } + else { result = HtmlLoader.loadHtml(this, "StrongLinksHint.html"); + fishName = "1 Finned Sashimi " + fishName; + for (int i = 1; i < linksNumber; i++) + fishName = "2x" + fishName; + } String name = getName(); String firstLinkName = this.baseLinkRegion[q[0]].toFullString(); String lastLinkName = this.baseLinkRegion[q[linksNumber - 1]].toFullString(); @@ -182,7 +189,6 @@ public String toHtml(Grid grid) { middleShared += ", " +this.shareRegion[i].toFullString(); String numberOfStrongLinks = Integer.toString(linksNumber); String numberOfWeakLinks = Integer.toString(linksNumber - 1); - String fishName = getFishName(linksNumber); String value = Integer.toString(this.value); String cell1 = startCell.toString(); String cell2 = endCell.toString(); diff --git a/diuf/sudoku/solver/rules/chaining/Chaining.java b/diuf/sudoku/solver/rules/chaining/Chaining.java index 94d8953..4cc104a 100644 --- a/diuf/sudoku/solver/rules/chaining/Chaining.java +++ b/diuf/sudoku/solver/rules/chaining/Chaining.java @@ -930,7 +930,15 @@ private Collection