Examples of EightPuzzleBoard


Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

  @Test
  public void testPosition9MoveRight() {
    // { 6, 5, 4, 7, 1, 8, 3, 2, 0 }
    setGapToPosition9();
    board.moveGapRight();
    Assert.assertEquals(new EightPuzzleBoard(new int[] { 6, 5, 4, 7, 1, 8,
        3, 2, 0 }), board);
  }
View Full Code Here

Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

public class EightPuzzleBoardTest {
  EightPuzzleBoard board;

  @Before
  public void setUp() {
    board = new EightPuzzleBoard();
  }
View Full Code Here

Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

public class EightPuzzleFunctionFactoryTest {
  EightPuzzleBoard board;

  @Before
  public void setUp() {
    board = new EightPuzzleBoard(new int[] { 1, 2, 5, 3, 4, 0, 6, 7, 8 });
  }
View Full Code Here

Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

    List<Action> actions = new ArrayList<Action>(EightPuzzleFunctionFactory
        .getActionsFunction().actions(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) EightPuzzleFunctionFactory
        .getResultFunction().result(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) EightPuzzleFunctionFactory
        .getResultFunction().result(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) (EightPuzzleBoard) EightPuzzleFunctionFactory
        .getResultFunction().result(board, actions.get(2));
    Assert.assertEquals(expectedThird, actualThird);
    Assert.assertEquals(EightPuzzleBoard.LEFT, actions.get(2));
  }
View Full Code Here

Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

  }

  @Test
  public void testGenerateCorrectWhenGapMovedRightward() {
    board.moveGapLeft();// gives { 1, 2, 5, 3, 0, 4, 6, 7, 8 }
    Assert.assertEquals(new EightPuzzleBoard(new int[] { 1, 2, 5, 3, 0, 4,
        6, 7, 8 }), board);

    List<Action> actions = new ArrayList<Action>(EightPuzzleFunctionFactory
        .getActionsFunction().actions(board));
    Assert.assertEquals(4, actions.size());

    EightPuzzleBoard expectedFourth = new EightPuzzleBoard(new int[] { 1,
        2, 5, 3, 4, 0, 6, 7, 8 });
    EightPuzzleBoard actualFourth = (EightPuzzleBoard) (EightPuzzleBoard) EightPuzzleFunctionFactory
        .getResultFunction().result(board, actions.get(3));
    Assert.assertEquals(expectedFourth, actualFourth);
    Assert.assertEquals(EightPuzzleBoard.RIGHT, actions.get(3));
  }
View Full Code Here

Examples of aima.core.environment.eightpuzzle.EightPuzzleBoard

public class MisplacedTileHeuristicFunctionTest {

  @Test
  public void testHeuristicCalculation() {
    MisplacedTilleHeuristicFunction fn = new MisplacedTilleHeuristicFunction();
    EightPuzzleBoard board = new EightPuzzleBoard(new int[] { 2, 0, 5, 6,
        4, 8, 3, 7, 1 });
    Assert.assertEquals(7.0, fn.h(board), 0.001);

    board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 0, 7, 1 });
    Assert.assertEquals(6.0, fn.h(board), 0.001);

    board = new EightPuzzleBoard(new int[] { 6, 2, 5, 3, 4, 8, 7, 0, 1 });
    Assert.assertEquals(7.0, fn.h(board), 0.001);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.