This commit is contained in:
@@ -17,11 +17,6 @@ public class MutableCell extends Cell{
|
|||||||
this.possibleSymbols = new ArrayList<>();
|
this.possibleSymbols = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MutableCell(MutableCell currentCell) {
|
|
||||||
super(currentCell);
|
|
||||||
this.possibleSymbols = currentCell.getPossibleSymbols();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSymbolIndex(int symbolIndex) {
|
public void setSymbolIndex(int symbolIndex) {
|
||||||
this.symbolIndex = symbolIndex;
|
this.symbolIndex = symbolIndex;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,10 @@ public class SudokuFactory {
|
|||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
int index = ((y + blockY * height) * size + (x + blockX * width));
|
int index = ((y + blockY * height) * size + (x + blockX * width));
|
||||||
Cell blockCell = cells.get(index);
|
Cell blockCell = cells.get(index);
|
||||||
List<Block> blockContainers = new ArrayList<>();
|
blockCell.setBlock(newBlock);
|
||||||
blockContainers.add(newBlock);
|
// List<Block> blockContainers = new ArrayList<>();
|
||||||
blockCell.setBlockContainers(blockContainers);
|
// blockContainers.add(newBlock);
|
||||||
|
// blockCell.setBlockContainers(blockContainers);
|
||||||
newBlock.addCell(blockCell);
|
newBlock.addCell(blockCell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class Solver {
|
|||||||
|
|
||||||
int symbol = currentCell.getPossibleSymbols().get(0);
|
int symbol = currentCell.getPossibleSymbols().get(0);
|
||||||
currentCell.setSymbolIndex(symbol);
|
currentCell.setSymbolIndex(symbol);
|
||||||
stack.push(new MutableCell(currentCell));
|
// stack.push(new MutableCell(currentCell));
|
||||||
try {
|
try {
|
||||||
doku.updateSymbolsPossibilities();
|
doku.updateSymbolsPossibilities();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package sudoku;
|
|||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import sudoku.io.SudokuPrinter;
|
import sudoku.io.SudokuPrinter;
|
||||||
@@ -19,9 +21,13 @@ public class SudokuSerializerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testSerialize() {
|
void testSerialize() {
|
||||||
int blockWidth = 3;
|
int testCount = 5;
|
||||||
int blockHeight = 3;
|
Random r = new Random();
|
||||||
testSerializeWithSize(blockWidth, blockHeight);
|
for (int i = 0; i < testCount; i++) {
|
||||||
|
int blockWidth = r.nextInt(20) + 1;
|
||||||
|
int blockHeight = r.nextInt(20) + 1;
|
||||||
|
testSerializeWithSize(blockWidth, blockHeight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user