use of aima.core.environment.eightpuzzle.EightPuzzleBoard in project aima-java by aimacode.
the class EightPuzzleBoardMoveTest method testPosition2MoveUp.
@Test
public void testPosition2MoveUp() {
// { 5, 0, 4, 6, 1, 8, 7, 3, 2 }
setGapToPosition2();
board.moveGapUp();
Assert.assertEquals(new EightPuzzleBoard(new int[] { 5, 0, 4, 6, 1, 8, 7, 3, 2 }), board);
}
use of aima.core.environment.eightpuzzle.EightPuzzleBoard in project aima-java by aimacode.
the class EightPuzzleBoardMoveTest method testPosition8MoveLeft.
@Test
public void testPosition8MoveLeft() {
// { 6, 5, 4, 7, 1, 8, 3, 0, 2 }
setGapToPosition8();
board.moveGapLeft();
Assert.assertEquals(new EightPuzzleBoard(new int[] { 6, 5, 4, 7, 1, 8, 0, 3, 2 }), board);
}
use of aima.core.environment.eightpuzzle.EightPuzzleBoard in project aima-java by aimacode.
the class EightPuzzleFunctionsTest method testGenerateCorrect3Successors.
@Test
public void testGenerateCorrect3Successors() {
List<Action> actions = new ArrayList<>(EightPuzzleFunctions.getActions(board));
Assert.assertEquals(3, actions.size());
// test first successor
EightPuzzleBoard expectedFirst = new EightPuzzleBoard(new int[] { 1, 2, 0, 3, 4, 5, 6, 7, 8 });
EightPuzzleBoard actualFirst = (EightPuzzleBoard) EightPuzzleFunctions.getResult(board, actions.get(0));
Assert.assertEquals(expectedFirst, actualFirst);
Assert.assertEquals(EightPuzzleBoard.UP, actions.get(0));
// test second successor
EightPuzzleBoard expectedSecond = new EightPuzzleBoard(new int[] { 1, 2, 5, 3, 4, 8, 6, 7, 0 });
EightPuzzleBoard actualSecond = (EightPuzzleBoard) EightPuzzleFunctions.getResult(board, actions.get(1));
Assert.assertEquals(expectedSecond, actualSecond);
Assert.assertEquals(EightPuzzleBoard.DOWN, actions.get(1));
// test third successor
EightPuzzleBoard expectedThird = new EightPuzzleBoard(new int[] { 1, 2, 5, 3, 0, 4, 6, 7, 8 });
EightPuzzleBoard actualThird = (EightPuzzleBoard) EightPuzzleFunctions.getResult(board, actions.get(2));
Assert.assertEquals(expectedThird, actualThird);
Assert.assertEquals(EightPuzzleBoard.LEFT, actions.get(2));
}
use of aima.core.environment.eightpuzzle.EightPuzzleBoard in project aima-java by aimacode.
the class EightPuzzleBoardMoveTest method testPosition1MoveDown.
@Test
public void testPosition1MoveDown() {
board.moveGapDown();
Assert.assertEquals(new EightPuzzleBoard(new int[] { 6, 5, 4, 0, 1, 8, 7, 3, 2 }), board);
}
use of aima.core.environment.eightpuzzle.EightPuzzleBoard in project aima-java by aimacode.
the class EightPuzzleBoardMoveTest method testPosition5MoveLeft.
@Test
public void testPosition5MoveLeft() {
// { 6, 5, 4, 1, 0, 8, 7, 3, 2 }
setGapToPosition5();
board.moveGapLeft();
Assert.assertEquals(new EightPuzzleBoard(new int[] { 6, 5, 4, 0, 1, 8, 7, 3, 2 }), board);
}
Aggregations