Commit 1e171201 authored by Peer Beckmann's avatar Peer Beckmann

Add a test to the backtrack solver.

parent 61003e6f
......@@ -10,8 +10,8 @@ public class Main {
runtimeInSeconds = System.currentTimeMillis();
int[] rightColumn = {6,6,2,5};
int[] bottomRow = {6,6,2,5};
// int[] rightColumn = {6,6,2,5};
// int[] bottomRow = {6,6,2,5};
//0.001s
// int[] rightColumn = {1,5,6,10,6};
......@@ -20,15 +20,15 @@ public class Main {
// int[] rightColumn = {16,5,7,9,7,9};
// int[] bottomRow = {6,7,4,11,12,6};
//0.003s
//0.002s
// int[] rightColumn = {9,17,16,12,6,24,14};
// int[] bottomRow = {21,15,7,9,19,23,10};
//0,104s
int[] rightColumn = {9,17,16,12,6,24,14};
int[] bottomRow = {21,15,7,9,19,23,10};
//0,109s
// int[] rightColumn = {26,26,23,16,18,4,9,17};
// int[] bottomRow = {19,15,32,7,23,27,6,4};
//0,097s
//0,033s
// int[] rightColumn = {12,37,21,12,4,29,24,5,39,5};
// int[] bottomRow = {34,3,7,37,11,14,8,13,28,24};
......
......@@ -7,7 +7,7 @@ import org.netzmail.kakurasu_solver.dataObjects.Board;
*
* @author Peer Beckmann
*/
public class BacktrackSolver extends Thread{
public class BacktrackSolver {
private final int[] bottomRow, rightColumn;
private final int size;
private final Board board;
......@@ -49,9 +49,9 @@ public class BacktrackSolver extends Thread{
public boolean solve(int row, int column) {
// System.out.println("ROW " + row + " COLUMN " + column);
//
// try {
// Thread.sleep(5);
// Thread.sleep(10);
// } catch (Exception e) {
// e.printStackTrace();
// }
......
package org.netzmail.kakurasu_solver.solver;
import org.junit.Before;
import org.junit.Test;
import org.netzmail.kakurasu_solver.dataObjects.Board;
import static org.junit.Assert.*;
/**
* Created by pbeckmann on 08.02.16.
*/
public class BacktrackSolverTest {
private int[] bottomRow, rightColumn;
@Before
public void setUp() throws Exception {
rightColumn = new int[]{6,6,2,5};
bottomRow = new int[]{6,6,2,5};
}
@Test
public void testMarkAllUnreachableFields() throws Exception {
Board board = new Board(bottomRow, rightColumn);
BacktrackSolver solver = new BacktrackSolver(board);
solver.markAllUnreachableFields();
assert board.isPositionUnreachable(3,3);
assert board.isPositionUnreachable(3,4);
assert board.isPositionUnreachable(4,3);
}
@Test
public void testSolve() throws Exception {
Board board = new Board(bottomRow, rightColumn);
BacktrackSolver solver = new BacktrackSolver(board);
solver.markAllUnreachableFields();
solver.solve(1,1);
System.out.print(board);
assert board.validateBoard();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment