Skip to content

Commit

Permalink
2 and 3 Strong links (Groupd)
Browse files Browse the repository at this point in the history
Improved both TurbotFish.java and ThreestrongLinks.java to accommodate Grouped strong links including ER and Line Grouped strong links. There is also the Grouped strong link in a box that is not ER as well. Clunky and may need some efiiciency related revision at some stage. some modifications to Grid.java to help in search for EmA in block/line constraints
  • Loading branch information
SudokuMonster committed Nov 4, 2019
1 parent 037ca4b commit a369bf0
Show file tree
Hide file tree
Showing 14 changed files with 1,509 additions and 510 deletions.
130 changes: 98 additions & 32 deletions diuf/sudoku/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -802,52 +802,118 @@ public static abstract class Region {
public abstract int getRegionTypeIndex();
public abstract int getRegionIndex();

//4 Cell set corresponds to cells in block that share exactly 2 columns and 2 rowes
private static int[][] blocksEmptyCells = new int[][] {
{4, 5, 7, 8},
{3, 5, 6, 8},
{3, 4, 6, 7},
{1, 2, 7, 8},
{0, 2, 6, 8},
{0, 1, 6, 7},
{1, 2, 4, 5},
{0, 2, 3, 5},
{0, 1, 3, 4},
{6, 7, 8, -1},
{3, 4, 5, -1},
{0, 1, 2, -1},
{2, 5, 8, -1},
{1, 4, 7, -1},
{0, 3, 6, -1}
};
//4 Cell set corresponds to cells in block that share exactly 1 column and 1 row or 2 lines
//without the cell at the intersection
private static int[][] blockGroupedCells = new int[][] {
{3, 6, -1, 1, 2, -1},
{4, 7, -1, 0, 2, -1},
{5, 8, -1, 0, 1, -1},
{0, 6, -1, 4, 5, -1},
{1, 7, -1, 3, 5, -1},
{2, 8, -1, 3, 4, -1},
{0, 3, -1, 7, 8, -1},
{1, 4, -1, 6, 8, -1},
{2, 5, -1, 6, 7, -1},
{0, 1, 2, 3, 4, 5},
{0, 1, 2, 6, 7, 8},
{3, 4, 5, 6, 7, 8},
{0, 3, 6, 1, 4, 7},
{0, 3, 6, 2, 5, 8},
{1, 4, 7, 2, 5, 8}
};
private static int[][] LineEmptyCells = new int[][] {
{0,1,2},
{3,4,5},
{6,7,8},
};
private static int[][] LineGroupedCells = new int[][] {
{3,4,5,6,7,8},
{0,1,2,6,7,8},
{0,1,2,3,4,5}
};
//4 Cell set corresponds to cells in block that share exactly 2 columns and 2 rowes
public BitSet Rectangle(int index) {
BitSet blockRectangleCellSet = new BitSet(9);
int[][] blocksRectangleCells = new int[][] {
{4, 5, 7, 8},
{3, 5, 6, 8},
{3, 4, 6, 7},
{1, 2, 7, 8},
{0, 2, 6, 8},
{0, 1, 6, 7},
{1, 2, 4, 5},
{0, 2, 3, 5},
{0, 1, 3, 4}
};
for(int i = 0; i < 4; i++) {
blockRectangleCellSet.set(blocksRectangleCells[index][i]);
}
return blockRectangleCellSet;
BitSet blockEmptyCellSet = new BitSet(10);
for(int i = 0; i < 4; i++)
if (blocksEmptyCells[index][i] >= 0)
blockEmptyCellSet.set(blocksEmptyCells[index][i]);
return blockEmptyCellSet;
}

//4 Cell set corresponds to cells in block that share exactly 1 column and 1 row
//without the cell at the intersection
public BitSet Cross(int index) {
BitSet blockCrossCellSet = new BitSet(9);
int[][] blocksCrossCells = new int[][] {
{3, 6, 1, 2},
{4, 7, 0, 2},
{5, 8, 0, 1},
{0, 6, 4, 5},
{1, 7, 3, 5},
{2, 8, 3, 4},
{0, 3, 7, 8},
{1, 4, 6, 8},
{2, 5, 6, 7}
};
for(int i = 0; i < 4; i++) {
blockCrossCellSet.set(blocksCrossCells[index][i]);
}
return blockCrossCellSet;
BitSet blockGroupedCellSet = new BitSet(10);
for(int i = 0; i < 6; i++)
if (blockGroupedCells[index][i] >= 0)
blockGroupedCellSet.set(blockGroupedCells[index][i]);
return blockGroupedCellSet;
}

//2 Cell set corresponds to cells in block Cross cells that share 1 row
//without the cell at the intersection
public BitSet crossBlade1(int index) {
BitSet blockGroupedCellSet = new BitSet(10);
for(int i = 0; i < 3; i++)
if (blockGroupedCells[index][i] >= 0)
blockGroupedCellSet.set(blockGroupedCells[index][i]);
return blockGroupedCellSet;
}

//2 Cell set corresponds to cells in block Cross cells that share 1 column
//without the cell at the intersection
public BitSet crossBlade2(int index) {
BitSet blockGroupedCellSet = new BitSet(10);
for(int i = 3; i < 6; i++)
if (blockGroupedCells[index][i] >= 0)
blockGroupedCellSet.set(blockGroupedCells[index][i]);
return blockGroupedCellSet;
}

//cellIndex of blockCell at centre of Cross Cell set
public int Heart(int index) {
int[] blocksHeartCells = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8};
return blocksHeartCells[index];
}

public BitSet lineEmptyCells(int index) {
BitSet lineEmptyCellSet = new BitSet(10);
for(int i = 0; i < 3; i++)
lineEmptyCellSet.set(LineEmptyCells[index][i]);
return lineEmptyCellSet;
}

public BitSet lineBlade1(int index) {
BitSet lineBladeCellSet = new BitSet(10);
for(int i = 0; i < 3; i++)
lineBladeCellSet.set(LineGroupedCells[index][i]);
return lineBladeCellSet;
}

public BitSet lineBlade2(int index) {
BitSet lineBladeCellSet = new BitSet(10);
for(int i = 0; i < 3; i++)
lineBladeCellSet.set(LineGroupedCells[index][i+3]);
return lineBladeCellSet;
}

/**
* Get a cell of this region by index. The order in which cells are
Expand Down
6 changes: 3 additions & 3 deletions diuf/sudoku/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
public class Settings {

public final static int VERSION = 1;
public final static int REVISION = 7;
public final static String SUBREV = ".4";
public final static String releaseDate = "2019-10-24";
public final static int REVISION = 8;
public final static String SUBREV = ".2";
public final static String releaseDate = "2019-11-04";
public final static String releaseYear = "2019";
public final static String releaseLicence = "Lesser General Public License";
public final static String releaseLicenceMini = "LGPL";
Expand Down
4 changes: 2 additions & 2 deletions diuf/sudoku/gui/EmptyRectangle.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<body>
<b>Empty Rectangle</b>: The Sudoku requires an Empty rectangle to solve.
<b>Empty Rectangle</b>: The Sudoku requires an 2 strong links one of which is an Empty rectangle to solve.
No skyscrapers, 2-String Kites or XY-Wings allowed.
Rating: 4.2
Rating: 4.3
</body>
</html>
Loading

0 comments on commit a369bf0

Please sign in to comment.