diff --git a/diuf/sudoku/Settings.java b/diuf/sudoku/Settings.java index c348056..c5c27f3 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 = ".5"; - public final static String releaseDate = "2019-12-15"; + public final static String SUBREV = ".7"; + public final static String releaseDate = "2019-12-18"; public final static String releaseYear = "2019"; public final static String releaseLicence = "Lesser General Public License"; public final static String releaseLicenceMini = "LGPL"; diff --git a/diuf/sudoku/gui/SudokuFrame.java b/diuf/sudoku/gui/SudokuFrame.java index 3cb8d8a..becaf96 100644 --- a/diuf/sudoku/gui/SudokuFrame.java +++ b/diuf/sudoku/gui/SudokuFrame.java @@ -200,6 +200,8 @@ private void repaintHint() { //SudokuMonster: Some changes in gui to limit colour salad in DG if (!Settings.getInstance().isDG()) sudokuPanel.setGreenCells(Collections.singleton(dHint.getCell())); + else + sudokuPanel.setHighlightedCells(new Cell[] {dHint.getCell()}); BitSet values = new BitSet(10); values.set(dHint.getValue()); sudokuPanel.setGreenPotentials(Collections.singletonMap( @@ -210,8 +212,11 @@ private void repaintHint() { sudokuPanel.setGreenPotentials(iHint.getGreenPotentials(sudokuPanel.getSudokuGrid(), viewNum)); sudokuPanel.setRedPotentials(iHint.getRedPotentials(sudokuPanel.getSudokuGrid(), viewNum)); sudokuPanel.setBluePotentials(iHint.getBluePotentials(sudokuPanel.getSudokuGrid(), viewNum)); - if (iHint.getSelectedCells() != null && !Settings.getInstance().isDG()) - sudokuPanel.setGreenCells(Arrays.asList(iHint.getSelectedCells())); + if (iHint.getSelectedCells() != null) + if (!Settings.getInstance().isDG()) + sudokuPanel.setGreenCells(Arrays.asList(iHint.getSelectedCells())); + else + sudokuPanel.setHighlightedCells(iHint.getSelectedCells()); if (iHint instanceof WarningHint) sudokuPanel.setRedCells(((WarningHint)iHint).getRedCells()); // Set links (rendered as arrows) @@ -1511,7 +1516,7 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitX() { if (mitX == null) { mitX = new JCheckBoxMenuItem(); - mitX.setText("Add X main diagonals"); + 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() { @@ -1534,7 +1539,7 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitDG() { if (mitDG == null) { mitDG = new JCheckBoxMenuItem(); - mitDG.setText("Add Disjoint Groups"); + mitDG.setText("Disjoint Groups"); mitDG.setSelected(false); mitDG.setToolTipText("Add 9 disjoint groups"); mitDG.addItemListener(new java.awt.event.ItemListener() { @@ -1557,9 +1562,9 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitWindows() { if (mitWindows == null) { mitWindows = new JCheckBoxMenuItem(); - mitWindows.setText("Add Windows"); + mitWindows.setText("Windows"); mitWindows.setSelected(false); - mitWindows.setToolTipText("Add Window groups (Use for Windoku)"); + mitWindows.setToolTipText("Add Window groups (Use for Windoku, Hypersudoku)"); mitWindows.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent e) { Settings.getInstance().setWindows(mitWindows.isSelected()); @@ -1580,7 +1585,7 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitAsterisk() { if (mitAsterisk == null) { mitAsterisk = new JCheckBoxMenuItem(); - mitAsterisk.setText("Add Asterisk"); + mitAsterisk.setText("Asterisk"); mitAsterisk.setSelected(false); mitAsterisk.setToolTipText("Adds 9-cell ASTERISK extra group"); mitAsterisk.addItemListener(new java.awt.event.ItemListener() { @@ -1609,7 +1614,7 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitCD() { if (mitCD == null) { mitCD = new JCheckBoxMenuItem(); - mitCD.setText("Add CD"); + mitCD.setText("Center Dot"); mitCD.setSelected(false); mitCD.setToolTipText("Adds 9-cell CENTER DOT extra group"); mitCD.addItemListener(new java.awt.event.ItemListener() { @@ -1638,7 +1643,7 @@ public void itemStateChanged(java.awt.event.ItemEvent e) { private JCheckBoxMenuItem getMitGirandola() { if (mitGirandola == null) { mitGirandola = new JCheckBoxMenuItem(); - mitGirandola.setText("Add Girandola"); + mitGirandola.setText("Girandola"); mitGirandola.setSelected(false); mitGirandola.setToolTipText("Adds 9-cell GIRANDOLA extra group"); mitGirandola.addItemListener(new java.awt.event.ItemListener() { diff --git a/diuf/sudoku/gui/SudokuPanel.java b/diuf/sudoku/gui/SudokuPanel.java index a5e53df..4ee9681 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; + private Cell[] highlightedCells; private Collection links; private SudokuFrame parent; @@ -337,6 +338,9 @@ public void setBlueRegions(Grid.Region... regions) { this.blueRegions = regions; } + public void setHighlightedCells(Cell[] cells) { + this.highlightedCells = cells; + } public void setLinks(Collection links) { this.links = links; } @@ -529,6 +533,7 @@ protected void paintComponent(Graphics g) { paintSelectionAndFocus(g); paintGrid(g); paintHighlightedRegions(g); + paintOutlineSingleCells(g); paintCellsValues(g); paintLinks(g); paintCellsPotentials(g); @@ -679,7 +684,32 @@ private void paintWindows(Graphics g) { } } - + +//@SudokuMonster: Small Square Cell outline designed to replace yellow cell background highlighting in multi-colour variants (e.g. Disjoint groups) + private void paintOutlineSingleCells(Graphics g) { + if (highlightedCells != null) { + Color[] colors = new Color[] {Color.orange, new Color(255, 128, 0)}; + for (int rev = 0; rev < 2; rev++) { + for (int i = 0; i < 1; i++) { + int x, y, w, h; // coordinates, width, height (in cells) + g.setColor(colors[1]); + for (int j = 0; j < highlightedCells.length ; j++) { + if (highlightedCells[j] == null) + continue; + x = highlightedCells[j].getX(); + y = highlightedCells[j].getY(); + w = 1; + h = 1; + for (int s = -2 + rev; s <= 2; s++) { + g.drawRect(x * CELL_OUTER_SIZE + (CELL_PAD + 4) + s, y * CELL_OUTER_SIZE + (CELL_PAD + 4) + s, + w * (CELL_INNER_SIZE - 8) - s * 2, h * (CELL_INNER_SIZE - 8) - s * 2); + } + } + } + } + } + } + private void paintHighlightedRegions(Graphics g) { if (blueRegions != null) { Color[] colors = new Color[] {new Color(0, 128, 0), new Color(255, 0, 0)}; @@ -687,7 +717,6 @@ private void paintHighlightedRegions(Graphics g) { for (int i = 0; i < blueRegions.length; i++) { int index = (rev == 0 ? i : blueRegions.length - 1 - i); Grid.Region region = blueRegions[index]; - //@SudokuMonster: Temp arrangement to disable Region highlighting for regions in variants int x, y, w, h; // coordinates, width, height (in cells) if (region != null) if (region.getRegionTypeIndex() < 3) { @@ -723,6 +752,7 @@ private void paintHighlightedRegions(Graphics g) { } } else { +//@SudokuMonster: individual cells of region outlined in variants g.setColor(colors[index % 2]); for (int j = 0; j < 9 ; j++) { x = region.getRegionCellIndexColumn(j); diff --git a/diuf/sudoku/solver/rules/AlignedExclusionHint.java b/diuf/sudoku/solver/rules/AlignedExclusionHint.java index 2da4068..c2baa49 100644 --- a/diuf/sudoku/solver/rules/AlignedExclusionHint.java +++ b/diuf/sudoku/solver/rules/AlignedExclusionHint.java @@ -211,7 +211,7 @@ else if (i > 0) } builder.append(" because "); if (lockCell == null) { - builder.append("the same value cannot occur twice in the same row, column or block"); + builder.append("the same value cannot occur twice in the same " + sharedRegions()); } else { builder.append("the cell " + lockCell.toString() + " must already contain "); //builder.append(ValuesFormatter.formatValues(lockCell.getPotentialValues(), " or ")); @@ -221,6 +221,39 @@ else if (i > 0) builder.append("
"); } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result; diff --git a/diuf/sudoku/solver/rules/Grouped2LinksFishHint.html b/diuf/sudoku/solver/rules/Grouped2LinksFishHint.html index 0e57f08..31cd5ed 100644 --- a/diuf/sudoku/solver/rules/Grouped2LinksFishHint.html +++ b/diuf/sudoku/solver/rules/Grouped2LinksFishHint.html @@ -10,11 +10,11 @@

{0}

the arrangement of cells with value {1} in {6} and in {7} (Green outlined regions) form strong links (conjugate pairs shown as green values) or grouped strong - links (yellow cell background). These strong links are weakly linked through {8} (Red outlined region). + links (orange cell outline or yellow cell background). These strong links are weakly linked through {8} (Red outlined region).

Any occurrence of the value {1} can therefore be removed from - any cells sharing a row, column or block with all cells with value + any cells sharing a {9} with all cells with value {1} in {6} and {7} that are not part of {8}.

@@ -27,9 +27,10 @@

{0}

The inference of a strong link from a group of cells with value {1} in any region can be spotted when a an "Empty mini Area (EmA)" is observed. This EmA - could be an empty mini-Line (EmL) in a row, column or block. In the case of "Empty + could be an empty mini-Line (EmL) in a {9}. In the case of "Empty rectangle" the EmA is a group of empty cells that can also be referred to as - "Empty mini Rectangle (EmR)". + "Empty mini Rectangle (EmR)". Variants like "Disjoint groups" and "Windows" can + infer a strong link from cell arrangements similar to blocks.

\ No newline at end of file diff --git a/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html b/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html index 99a711f..2e19af1 100644 --- a/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html +++ b/diuf/sudoku/solver/rules/GroupedStrongLinksHint.html @@ -10,7 +10,7 @@

{0}

the arrangement of cells with value {1} in {2} and {3} form strong links (conjugate pairs, shown as green values) or grouped strong - links (yellow cell background). These strong links are weakly linked to each other via + links (orange cell outline or yellow cell background). These strong links are weakly linked to each other via {6} and {7} (Red or Green outlined region).

diff --git a/diuf/sudoku/solver/rules/ERFishHint.html b/diuf/sudoku/solver/rules/GroupedTCFishHint.html similarity index 62% rename from diuf/sudoku/solver/rules/ERFishHint.html rename to diuf/sudoku/solver/rules/GroupedTCFishHint.html index 78b2bda..80e46e1 100644 --- a/diuf/sudoku/solver/rules/ERFishHint.html +++ b/diuf/sudoku/solver/rules/GroupedTCFishHint.html @@ -9,18 +9,20 @@

{0}

The value {1} in {6} forms a strong link (conjugate pair) while the arrangement of cells with value {1} in {7} forms a pattern known as Empty rectangle where all cells with value {1} - (yellow) can be mapped on one row and one column. The bridge cell - {3} shares {8} with some cell(s) that have the value {1} - in {7} therefore forming a weak link. + (orange cell outline or yellow cell background) can be mapped on one row and one column. + The bridge cell {3} shares {8} with some cell(s) that have the + value {1} in {7} therefore forming a weak link.

Any occurrence of the value {1} can therefore be - removed from any cells sharing a row, column or block + removed from any cells sharing a {9} with both start cell {2} and {7} cells with value {1} that are not part of {8}.

- This technique is similar to a 2x2 Finned Franken X-Wing technique logic. + This technique is similar to a 2x2 Finned Franken X-Wing technique logic. It + is worth noting that some variants like "Disjoint groups" and "Windows" can + display the same pattern of an "Empty rectangle"

\ No newline at end of file diff --git a/diuf/sudoku/solver/rules/NakedSetGenHint.java b/diuf/sudoku/solver/rules/NakedSetGenHint.java index e047f8e..b96b0c5 100644 --- a/diuf/sudoku/solver/rules/NakedSetGenHint.java +++ b/diuf/sudoku/solver/rules/NakedSetGenHint.java @@ -38,9 +38,7 @@ public int getViewCount() { @Override public Cell[] getSelectedCells() { - if (Settings.getInstance().isDG()) - return null; - return cells; + return cells; } @Override @@ -117,7 +115,7 @@ public String toString() { StringBuilder builder = new StringBuilder(); builder.append(getName()); builder.append(": "); - if (cells.length <= 4) + if (cells.length <= 6) builder.append(Cell.toFullString(this.cells)); else builder.append("Cells [...]"); diff --git a/diuf/sudoku/solver/rules/TurbotFishHint.html b/diuf/sudoku/solver/rules/TurbotFishHint.html index 27e6db8..06a0370 100644 --- a/diuf/sudoku/solver/rules/TurbotFishHint.html +++ b/diuf/sudoku/solver/rules/TurbotFishHint.html @@ -10,7 +10,7 @@

{0}

Any occurrence of the value {1} can therefore be - removed from any cells sharing a row, column or block + removed from any cells sharing a {9} with both start cells {2} and {5}.

diff --git a/diuf/sudoku/solver/rules/TurbotFishHint.java b/diuf/sudoku/solver/rules/TurbotFishHint.java index 364a369..fddffdd 100644 --- a/diuf/sudoku/solver/rules/TurbotFishHint.java +++ b/diuf/sudoku/solver/rules/TurbotFishHint.java @@ -114,11 +114,44 @@ public String toString() { value; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result; if ((emptyRegion1 && baseSet.getRegionTypeIndex() == 0) || (emptyRegion2 && coverSet.getRegionTypeIndex() == 0)) - result = HtmlLoader.loadHtml(this, "ERFishHint.html"); + result = HtmlLoader.loadHtml(this, "GroupedTCFishHint.html"); else if (emptyRegion1 || emptyRegion2) result = HtmlLoader.loadHtml(this, "Grouped2LinksFishHint.html"); else @@ -132,7 +165,7 @@ else if (emptyRegion1 || emptyRegion2) String cell2 = bridgeCell1.toString(); String cell3 = bridgeCell2.toString(); String cell4 = endCell.toString(); - result = HtmlLoader.format(result, name, value, cell1, cell2, cell3, cell4, base, cover, shared); + result = HtmlLoader.format(result, name, value, cell1, cell2, cell3, cell4, base, cover, shared, sharedRegions()); return result; } @@ -194,7 +227,7 @@ public String getName() { @Override public String getShortName() { if ((emptyRegion1 && baseSet.getRegionTypeIndex() == 0) || (emptyRegion2 && coverSet.getRegionTypeIndex() == 0)) - return "ER" + getSuffix(); + return "gTC" + getSuffix(); if ((emptyRegion1 || emptyRegion2) && baseSet.getRegionTypeIndex() == coverSet.getRegionTypeIndex()) return "gSky" + getSuffix(); if (emptyRegion1 || emptyRegion2) diff --git a/diuf/sudoku/solver/rules/VWXYZWingHint.html b/diuf/sudoku/solver/rules/VWXYZWingHint.html index 7ef0d9c..9bdda98 100644 --- a/diuf/sudoku/solver/rules/VWXYZWingHint.html +++ b/diuf/sudoku/solver/rules/VWXYZWingHint.html @@ -13,7 +13,7 @@

VWXYZ-Wing {12}{10}{11}

Other occurances of the value {5} can therefore be removed - from any cells sharing a row, column or block with all Wing cells + from any cells sharing a {13} with all Wing cells containing the value {5}.

diff --git a/diuf/sudoku/solver/rules/VWXYZWingHint.java b/diuf/sudoku/solver/rules/VWXYZWingHint.java index dbf8656..bfb8920 100644 --- a/diuf/sudoku/solver/rules/VWXYZWingHint.java +++ b/diuf/sudoku/solver/rules/VWXYZWingHint.java @@ -198,9 +198,7 @@ public Region[] getRegions() { @Override public Cell[] getSelectedCells() { - if (Settings.getInstance().isDG()) - return null; - return new Cell[] {vwxyzCell, vzCell, wzCell, xzCell, yzCell}; + return new Cell[] {vwxyzCell, vzCell, wzCell, xzCell, yzCell}; } @Override @@ -275,6 +273,39 @@ public String toString() { xValue + "," + zValue; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result; @@ -287,7 +318,7 @@ public String toHtml(Grid grid) { String cell3 = wzCell.toString(); String cell4 = xzCell.toString(); String cell5 = yzCell.toString(); - result = HtmlLoader.format(result, cell1, cell2, cell3, cell4, cell5, zValue, getW(grid), getY(grid), getV(grid), xValue, biggestCardinality, wingSize, (doubleLink ? 2 : 1)); + result = HtmlLoader.format(result, cell1, cell2, cell3, cell4, cell5, zValue, getW(grid), getY(grid), getV(grid), xValue, biggestCardinality, wingSize, (doubleLink ? 2 : 1), sharedRegions()); return result; } } diff --git a/diuf/sudoku/solver/rules/WXYZWingHint.html b/diuf/sudoku/solver/rules/WXYZWingHint.html index 065eebb..106745a 100644 --- a/diuf/sudoku/solver/rules/WXYZWingHint.html +++ b/diuf/sudoku/solver/rules/WXYZWingHint.html @@ -13,7 +13,7 @@

WXYZ-Wing {11}{9}{10}

Other occurances of the value {4} can therefore be removed - from any cells sharing a row, column or block with all Wing cells + from any cells sharing a {12} with all Wing cells containing the value {4}.

diff --git a/diuf/sudoku/solver/rules/WXYZWingHint.java b/diuf/sudoku/solver/rules/WXYZWingHint.java index 6c0eeec..2ac4019 100644 --- a/diuf/sudoku/solver/rules/WXYZWingHint.java +++ b/diuf/sudoku/solver/rules/WXYZWingHint.java @@ -247,6 +247,39 @@ public String toString() { xValue + "," + zValue; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result; @@ -258,7 +291,7 @@ public String toHtml(Grid grid) { String cell2 = wzCell.toString(); String cell3 = xzCell.toString(); String cell4 = yzCell.toString(); - result = HtmlLoader.format(result, cell1, cell2, cell3, cell4, zValue, getX(grid), getY(grid), getZ(grid), xValue, biggestCardinality, wingSize, (doubleLink ? 2 : 1)); + result = HtmlLoader.format(result, cell1, cell2, cell3, cell4, zValue, getX(grid), getY(grid), getZ(grid), xValue, biggestCardinality, wingSize, (doubleLink ? 2 : 1), sharedRegions()); return result; } } diff --git a/diuf/sudoku/solver/rules/XYWingHint.html b/diuf/sudoku/solver/rules/XYWingHint.html index 2145774..09bc6d8 100644 --- a/diuf/sudoku/solver/rules/XYWingHint.html +++ b/diuf/sudoku/solver/rules/XYWingHint.html @@ -12,7 +12,7 @@

XY-Wing

Other occurances of the value {3} can therefore be removed from any - cells sharing a row, column or block with both {1} and {2}. + cells sharing a {6} with both {1} and {2}.

\ No newline at end of file diff --git a/diuf/sudoku/solver/rules/XYWingHint.java b/diuf/sudoku/solver/rules/XYWingHint.java index a850f77..06775c5 100644 --- a/diuf/sudoku/solver/rules/XYWingHint.java +++ b/diuf/sudoku/solver/rules/XYWingHint.java @@ -197,6 +197,39 @@ public String toString() { return builder.toString(); } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result; @@ -207,7 +240,7 @@ public String toHtml(Grid grid) { String cell1 = xyCell.toString(); String cell2 = xzCell.toString(); String cell3 = yzCell.toString(); - result = HtmlLoader.format(result, cell1, cell2, cell3, value, getX(grid), getY(grid)); + result = HtmlLoader.format(result, cell1, cell2, cell3, value, getX(grid), getY(grid), sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/XYZWingHint.html b/diuf/sudoku/solver/rules/XYZWingHint.html index 228b01f..b00271c 100644 --- a/diuf/sudoku/solver/rules/XYZWingHint.html +++ b/diuf/sudoku/solver/rules/XYZWingHint.html @@ -14,7 +14,7 @@

XYZ-Wing

Other occurances of the value {3} can therefore be removed from any - cells sharing a row, column or block with all the three cells. + cells sharing a {6} with all the three cells.

\ No newline at end of file diff --git a/diuf/sudoku/solver/rules/chaining/CycleHint.java b/diuf/sudoku/solver/rules/chaining/CycleHint.java index fa380b9..ed75879 100644 --- a/diuf/sudoku/solver/rules/chaining/CycleHint.java +++ b/diuf/sudoku/solver/rules/chaining/CycleHint.java @@ -182,6 +182,39 @@ public String toString() { return getName() + ": " + Cell.toString(getSelectedCells()); } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String fileName; @@ -200,7 +233,7 @@ else if (isXChain) String onChain = getHtmlChain(dstOn); String offChain = getHtmlChain(dstOff); result = HtmlLoader.format(result, cells, value, commonName, - onChain, offChain); + onChain, offChain, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/chaining/X-Cycle.html b/diuf/sudoku/solver/rules/chaining/X-Cycle.html index f593637..8ed830d 100644 --- a/diuf/sudoku/solver/rules/chaining/X-Cycle.html +++ b/diuf/sudoku/solver/rules/chaining/X-Cycle.html @@ -4,7 +4,7 @@

Bidirectional X-Cycle {2}

The cells {0} form a bidirectional cycle: there are exactly two ways of placing the value {1} in these cells, forming two different possible - configurations. Some {1} appear in a row, column or block regardless of the + configurations. Some {1} appear in a {5} regardless of the chosen configuration. Because one of the two configurations must be correct, other occurances of the value {1} can be removed from these rows, columns or blocks.

diff --git a/diuf/sudoku/solver/rules/chaining/XY-Cycle.html b/diuf/sudoku/solver/rules/chaining/XY-Cycle.html index 6034a3b..251c624 100644 --- a/diuf/sudoku/solver/rules/chaining/XY-Cycle.html +++ b/diuf/sudoku/solver/rules/chaining/XY-Cycle.html @@ -4,7 +4,7 @@

Bidirectional Cycle

The cells {0} form a bidirectional cycle: there are exactly two ways of placing the values in these cells, forming two different possible - configurations. Some values appear in a row, column or block regardless of the + configurations. Some values appear in a {5} regardless of the chosen configuration. Because one of the two configurations must be correct, other occurances of these values can be removed from these rows, columns or blocks.

diff --git a/diuf/sudoku/solver/rules/chaining/Y-Cycle.html b/diuf/sudoku/solver/rules/chaining/Y-Cycle.html index 09f0a5e..2c114b5 100644 --- a/diuf/sudoku/solver/rules/chaining/Y-Cycle.html +++ b/diuf/sudoku/solver/rules/chaining/Y-Cycle.html @@ -4,7 +4,7 @@

Bidirectional Y-Cycle

The cells {0} form a bidirectional cycle: there are exactly two ways of placing the values in these cells, forming two different possible - configurations. Some values appear in a row, column or block regardless of the + configurations. Some values appear in a {5} regardless of the chosen configuration. Because one of the two configurations must be correct, other occurances of these values can be removed from these rows, columns or blocks.

diff --git a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave1.html b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave1.html index 039e2b0..a3bcf97 100644 --- a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave1.html +++ b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave1.html @@ -6,8 +6,8 @@

Bivalue Universal Grave type 1

Sudoku would exhibit a Bivalue Universal Grave pattern (or BUG).

- In a BUG, each value that remains in a row, column or block has exactly two - possible positions in that row, column or block; and each empty cell has exactly two + In a BUG, each value that remains in a {4} has exactly two + possible positions in that {4}; and each empty cell has exactly two possible values. A Sudoku having a BUG has zero, two or more valid solutions.

diff --git a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave2.html b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave2.html index b19e40c..7504f54 100644 --- a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave2.html +++ b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave2.html @@ -6,8 +6,8 @@

Bivalue Universal Grave type 2

Sudoku would exhibit a Bivalue Universal Grave pattern (or BUG).

- In a BUG, each value that remains in a row, column or block has exactly two - possible positions in that row, column or block; and each empty cell has exactly two + In a BUG, each value that remains in a {2} has exactly two + possible positions in that {2}; and each empty cell has exactly two possible values. A Sudoku having a BUG has zero, two or more valid solutions.

@@ -15,7 +15,7 @@

Bivalue Universal Grave type 2

Because a valid Sudoku has exactly one solution, the BUG cannot be part of it. The only way to avoid the BUG is if at least one of the cells {1} contains the value {0}. Other potential positions of this - value can therefore be removed from other cells sharing a row, column or block with + value can therefore be removed from other cells sharing a {2} with {1}.

diff --git a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave3.html b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave3.html index 73e3c3c..63f5885 100644 --- a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave3.html +++ b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave3.html @@ -6,8 +6,8 @@

Bivalue Universal Grave type 3 (with Naked {4})

Sudoku would exhibit a Bivalue Universal Grave pattern (or BUG).

- In a BUG, each value that remains in a row, column or block has exactly two - possible positions in that row, column or block; and each empty cell has exactly two + In a BUG, each value that remains in a {8} has exactly two + possible positions in that {8}; and each empty cell has exactly two possible values. A Sudoku having a BUG has zero, two or more valid solutions.

diff --git a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave4.html b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave4.html index 0332658..1340a12 100644 --- a/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave4.html +++ b/diuf/sudoku/solver/rules/unique/BivalueUniversalGrave4.html @@ -6,8 +6,8 @@

Bivalue Universal Grave type 4

Sudoku would exhibit a Bivalue Universal Grave pattern (or BUG).

- In a BUG, each value that remains in a row, column or block has exactly two - possible positions in that row, column or block; and each empty cell has exactly two + In a BUG, each value that remains in a {7} has exactly two + possible positions in that {7}; and each empty cell has exactly two possible values. A Sudoku having a BUG has zero, two or more valid solutions.

diff --git a/diuf/sudoku/solver/rules/unique/Bug1Hint.java b/diuf/sudoku/solver/rules/unique/Bug1Hint.java index 754b260..2a34b21 100644 --- a/diuf/sudoku/solver/rules/unique/Bug1Hint.java +++ b/diuf/sudoku/solver/rules/unique/Bug1Hint.java @@ -73,6 +73,39 @@ public String toString() { return "BUG type 1: " + bugCell.toString(); } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "BivalueUniversalGrave1.html"); @@ -80,7 +113,7 @@ public String toHtml(Grid grid) { String orExtra = ValuesFormatter.formatValues(bugValues, " or "); BitSet removable = super.getRemovablePotentials().get(bugCell); String remList = ValuesFormatter.formatValues(removable, " and "); - result = HtmlLoader.format(result, andExtra, bugCell, orExtra, remList); + result = HtmlLoader.format(result, andExtra, bugCell, orExtra, remList, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/unique/Bug2Hint.java b/diuf/sudoku/solver/rules/unique/Bug2Hint.java index 7df0d75..44b72ce 100644 --- a/diuf/sudoku/solver/rules/unique/Bug2Hint.java +++ b/diuf/sudoku/solver/rules/unique/Bug2Hint.java @@ -76,11 +76,44 @@ public String toString() { return "BUG type 2: " + Cell.toString(bugCells) + " on " + bugValue; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "BivalueUniversalGrave2.html"); String andBugCells = ValuesFormatter.formatCells(bugCells, " and "); - return HtmlLoader.format(result, bugValue, andBugCells); + return HtmlLoader.format(result, bugValue, andBugCells, sharedRegions()); } } diff --git a/diuf/sudoku/solver/rules/unique/Bug3Hint.java b/diuf/sudoku/solver/rules/unique/Bug3Hint.java index 9ca0ccc..d6eb631 100644 --- a/diuf/sudoku/solver/rules/unique/Bug3Hint.java +++ b/diuf/sudoku/solver/rules/unique/Bug3Hint.java @@ -96,6 +96,39 @@ public String toString() { + ValuesFormatter.formatValues(nakedSet, ", "); } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "BivalueUniversalGrave3.html"); @@ -110,7 +143,7 @@ public String toHtml(Grid grid) { String andNakedValues = ValuesFormatter.formatValues(nakedSet, " and "); String regionName = region.toString(); return HtmlLoader.format(result, andExtraValues, andBugCells, orBugCells, - orExtraValues, setName, andOtherCells, andNakedValues, regionName); + orExtraValues, setName, andOtherCells, andNakedValues, regionName, sharedRegions()); } } diff --git a/diuf/sudoku/solver/rules/unique/Bug4Hint.java b/diuf/sudoku/solver/rules/unique/Bug4Hint.java index 2aaa3b5..c8bc730 100644 --- a/diuf/sudoku/solver/rules/unique/Bug4Hint.java +++ b/diuf/sudoku/solver/rules/unique/Bug4Hint.java @@ -97,6 +97,39 @@ public String toString() { return "BUG type 4: " + bugCell1.toString() + "," + bugCell2.toString() + " on " + value; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "BivalueUniversalGrave4.html"); @@ -111,7 +144,7 @@ public String toHtml(Grid grid) { removable.or(r); String removableValues = ValuesFormatter.formatValues(removable, " and "); return HtmlLoader.format(result, bugValuesAnd, bugCellsAnd, bugCellsOr, bugValuesOr, - lockedValue, regionName, removableValues); + lockedValue, regionName, removableValues, sharedRegions()); } } diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType1.html b/diuf/sudoku/solver/rules/unique/UniqueLoopType1.html index c670fa3..7386197 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType1.html +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType1.html @@ -6,7 +6,7 @@

Unique {0} type 1

{1} and {2}. There are exactly two ways of placing the values {1} and {2} in the cells of the Unique {0}, forming two possible configurations. - In both configurations, each row, column or block touched by the Unique + In both configurations, each {5} touched by the Unique {0} contains each of the two values {1} and {2} exactly once. As a result, if one of these two configurations were part of the solution, it could then be replaced by the other one to get a second valid diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType1Hint.java b/diuf/sudoku/solver/rules/unique/UniqueLoopType1Hint.java index f3fc581..0cc0b07 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType1Hint.java +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType1Hint.java @@ -36,6 +36,40 @@ public int getType() { return 1; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "UniqueLoopType1.html"); @@ -44,7 +78,7 @@ public String toHtml(Grid grid) { Cell[] cells = new Cell[loop.size()]; loop.toArray(cells); String allCells = Cell.toString(cells); - result = HtmlLoader.format(result, type, v1, v2, allCells, cellName); + result = HtmlLoader.format(result, type, v1, v2, allCells, cellName, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType2.html b/diuf/sudoku/solver/rules/unique/UniqueLoopType2.html index 45d80e7..ecb2718 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType2.html +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType2.html @@ -6,7 +6,7 @@

Unique {0} type 2

{1} and {2}. There are exactly two ways of placing the values {1} and {2} in the cells of the Unique {0}, forming two possible configurations. - In both configurations, each row, column or block touched by the Unique + In both configurations, each {7} touched by the Unique {0} contains each of the two values {1} and {2} exactly once. As a result, if one of these two configurations were part of the solution, it could then be replaced by the other one to get a second valid @@ -18,7 +18,7 @@

Unique {0} type 2

value {6}.

Other occurances of the value {6} can therefore be removed from the - cells that share a row, column or block with {5}. + cells that share a {7} with {5}.

\ No newline at end of file diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType2Hint.java b/diuf/sudoku/solver/rules/unique/UniqueLoopType2Hint.java index f317102..44bc78a 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType2Hint.java +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType2Hint.java @@ -46,6 +46,39 @@ public int getType() { return 2; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid g) { String result = HtmlLoader.loadHtml(this, "UniqueLoopType2.html"); @@ -56,7 +89,7 @@ public String toHtml(Grid g) { String extraCellsOr = ValuesFormatter.formatCells(cells, " or "); String extraCellsAnd = ValuesFormatter.formatCells(cells, " and "); result = HtmlLoader.format(result, type, v1, v2, allCells, extraCellsOr, - extraCellsAnd, value); + extraCellsAnd, value, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType3Hidden.html b/diuf/sudoku/solver/rules/unique/UniqueLoopType3Hidden.html index 73a3477..29ff810 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType3Hidden.html +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType3Hidden.html @@ -6,7 +6,7 @@

Unique {0} type 3 (with Hidden {7})

{1} and {2}. There are exactly two ways of placing the values {1} and {2} in the cells of the Unique {0}, forming two possible configurations. - In both configurations, each row, column or block touched by the Unique + In both configurations, each {11} touched by the Unique {0} contains each of the two values {1} and {2} exactly once. As a result, if one of these two configurations were part of the solution, it could then be replaced by the other one to get a second valid diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType3HiddenHint.java b/diuf/sudoku/solver/rules/unique/UniqueLoopType3HiddenHint.java index addaeb1..539e6ea 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType3HiddenHint.java +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType3HiddenHint.java @@ -97,6 +97,39 @@ public int getType() { return 3; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "UniqueLoopType3Hidden.html"); @@ -107,8 +140,8 @@ public String toHtml(Grid grid) { String cell1 = c1.toString(); String cell2 = c2.toString(); String valuesOrName = ValuesFormatter.formatValues(otherValues, " or "); - final String[] setNames = new String[] {"Pair", "Triplet", "Quad", "Set (5)", - "Set (6)", "Set (7)"}; + final String[] setNames = new String[] {"Pair", "Triplet", "Quad", "Quintuplet", + "Sextuplet", "Septuplet"}; String setName = setNames[hiddenValues.cardinality() - 2]; Cell[] cells = new Cell[hiddenIndexes.length]; for (int i = 0; i < cells.length; i++) @@ -117,7 +150,7 @@ public String toHtml(Grid grid) { String valuesAndName = ValuesFormatter.formatValues(hiddenValues, " and "); String regionName = region.toString(); result = HtmlLoader.format(result, type, v1, v2, allCells, cell1, - cell2, valuesOrName, setName, otherCells, valuesAndName, regionName); + cell2, valuesOrName, setName, otherCells, valuesAndName, regionName, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType3Naked.html b/diuf/sudoku/solver/rules/unique/UniqueLoopType3Naked.html index de9bab3..22be40b 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType3Naked.html +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType3Naked.html @@ -6,7 +6,7 @@

Unique {0} type 3 (with Naked {7})

{1} and {2}. There are exactly two ways of placing the values {1} and {2} in the cells of the Unique {0}, forming two possible configurations. - In both configurations, each row, column or block touched by the Unique + In both configurations, each {11} touched by the Unique {0} contains each of the two values {1} and {2} exactly once. As a result, if one of these two configurations were part of the solution, it could then be replaced by the other one to get a second valid diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType3NakedHint.java b/diuf/sudoku/solver/rules/unique/UniqueLoopType3NakedHint.java index fcbad24..53a77bb 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType3NakedHint.java +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType3NakedHint.java @@ -84,6 +84,39 @@ public Grid.Region[] getRegions() { public int getType() { return 3; } + + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } @Override public String toHtml(Grid grid) { @@ -95,14 +128,14 @@ public String toHtml(Grid grid) { String cell1 = c1.toString(); String cell2 = c2.toString(); String valuesOrName = ValuesFormatter.formatValues(otherValues, " or "); - final String[] setNames = new String[] {"Pair", "Triplet", "Quad", "Set (5)", - "Set (6)", "Set (7)"}; + final String[] setNames = new String[] {"Pair", "Triplet", "Quad", "Quintuplet", + "Sextuplet", "Septuplet"}; String setName = setNames[nakedValues.length - 2]; String otherCells = ValuesFormatter.formatCells(cells, " and "); String valuesAndName = ValuesFormatter.formatValues(nakedValues, " and "); String regionName = region.toString(); result = HtmlLoader.format(result, type, v1, v2, allCells, cell1, - cell2, valuesOrName, setName, otherCells, valuesAndName, regionName); + cell2, valuesOrName, setName, otherCells, valuesAndName, regionName, sharedRegions()); return result; } diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType4.html b/diuf/sudoku/solver/rules/unique/UniqueLoopType4.html index ad37fab..59f6dcd 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType4.html +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType4.html @@ -6,7 +6,7 @@

Unique {0} type 4

{1} and {2}. There are exactly two ways of placing the values {1} and {2} in the cells of the Unique {0}, forming two possible configurations. - In both configurations, each row, column or block touched by the Unique + In both configurations, each {7} touched by the Unique {0} contains each of the two values {1} and {2} exactly once. As a result, if one of these two configurations were part of the solution, it could then be replaced by the other one to get a second valid diff --git a/diuf/sudoku/solver/rules/unique/UniqueLoopType4Hint.java b/diuf/sudoku/solver/rules/unique/UniqueLoopType4Hint.java index 2eda092..8e64aec 100644 --- a/diuf/sudoku/solver/rules/unique/UniqueLoopType4Hint.java +++ b/diuf/sudoku/solver/rules/unique/UniqueLoopType4Hint.java @@ -46,6 +46,39 @@ public int getType() { return 4; } + private String sharedRegions(){ + if (Settings.getInstance().isVanilla()) + return "row, column or block"; + else { + String res[] = new String[10]; + int i = 0; + String finalRes = "row"; + if (Settings.getInstance().isVLatin()) + return "row or column"; + else + res[i++]= "column"; + if (Settings.getInstance().isBlocks()) + res[i++]= "block"; + if (Settings.getInstance().isDG()) + res[i++]= "disjoint group"; + if (Settings.getInstance().isWindows()) + res[i++]= "window group"; + if (Settings.getInstance().isX()) + res[i++]= "diagonal"; + if (Settings.getInstance().isGirandola()) + res[i++]= "girandola group"; + if (Settings.getInstance().isAsterisk()) + res[i++]= "asterisk group"; + if (Settings.getInstance().isCD()) + res[i++]= "center dot group"; + i--; + for (int j = 0; j < i; j++) + finalRes += ", " + res[j]; + finalRes += " or " + res[i]; + return finalRes; + } + } + @Override public String toHtml(Grid grid) { String result = HtmlLoader.loadHtml(this, "UniqueLoopType4.html"); @@ -56,7 +89,7 @@ public String toHtml(Grid grid) { String cell1 = c1.toString(); String cell2 = c2.toString(); result = HtmlLoader.format(result, type, lockValue, remValue, allCells, cell1, - cell2, region.toString()); + cell2, region.toString(), sharedRegions()); return result; }