Examples of XYLocation


Examples of aima.core.util.datastructure.XYLocation

    Assert.assertEquals(2, env.getObjectsAt(loc).size());
  }

  @Test
  public void testGetObjectsNear() {
    XYLocation loc = new XYLocation(5, 5);
    env.moveObjectToAbsoluteLocation(a, loc);
    AbstractAgent b = new MockAgent();
    AbstractAgent c = new MockAgent();
    Wall w1 = new Wall();

    env.addObjectToLocation(b, new XYLocation(7, 4));
    env.addObjectToLocation(c, new XYLocation(5, 7));
    env.addObjectToLocation(w1, new XYLocation(3, 10));

    // at this point agent A should be able to see B and C but not the wall
    // with a "vision radius" of 3
    Set<EnvironmentObject> visibleToA = env.getObjectsNear(a, 3);
    Assert.assertEquals(2, visibleToA.size());
    // agent B should be able to see A only
    Set<EnvironmentObject> visibleToB = env.getObjectsNear(b, 3);
    Assert.assertEquals(1, visibleToB.size());

    // move B South
    env.moveObject(b, XYLocation.Direction.South);
    // at this point both a and c should be visible to b
    visibleToB = env.getObjectsNear(b, 3);
    Assert.assertEquals(2, visibleToB.size());
    // move c near the wall
    env.moveObjectToAbsoluteLocation(c, new XYLocation(3, 11));
    // only the wall should be visible
    Set<EnvironmentObject> visibleToC = env.getObjectsNear(c, 3);
    Assert.assertEquals(1, visibleToC.size());
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testMakePerimeter() {
    env.makePerimeter();
    Assert.assertTrue(env.isBlocked(new XYLocation(0, 0)));
    Assert.assertTrue(env.isBlocked(new XYLocation(0, 6)));
    Assert.assertTrue(env.isBlocked(new XYLocation(0, 11)));
    Assert.assertTrue(env.isBlocked(new XYLocation(6, 0)));
    Assert.assertTrue(env.isBlocked(new XYLocation(9, 0)));
    Assert.assertTrue(env.isBlocked(new XYLocation(9, 6)));
    Assert.assertTrue(env.isBlocked(new XYLocation(9, 11)));
    Assert.assertTrue(env.isBlocked(new XYLocation(6, 11)));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  @Test
  public void testSingleSquareBoard() {
    board = new NQueensBoard(1);
    Assert.assertFalse(goalTest.isGoalState(board));
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertTrue(goalTest.isGoalState(board));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  @Test
  public void testInCorrectPlacement() {
    Assert.assertFalse(goalTest.isGoalState(board));
    // This is the configuration of Figure 3.5 (b) in AIMA 2nd Edition
    board.addQueenAt(new XYLocation(0, 0));
    board.addQueenAt(new XYLocation(1, 2));
    board.addQueenAt(new XYLocation(2, 4));
    board.addQueenAt(new XYLocation(3, 6));
    board.addQueenAt(new XYLocation(4, 1));
    board.addQueenAt(new XYLocation(5, 3));
    board.addQueenAt(new XYLocation(6, 5));
    board.addQueenAt(new XYLocation(7, 7));
    Assert.assertFalse(goalTest.isGoalState(board));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  @Test
  public void testCorrectPlacement() {

    Assert.assertFalse(goalTest.isGoalState(board));
    // This is the configuration of Figure 5.9 (c) in AIMA 2nd Edition
    board.addQueenAt(new XYLocation(0, 1));
    board.addQueenAt(new XYLocation(1, 4));
    board.addQueenAt(new XYLocation(2, 6));
    board.addQueenAt(new XYLocation(3, 3));
    board.addQueenAt(new XYLocation(4, 0));
    board.addQueenAt(new XYLocation(5, 7));
    board.addQueenAt(new XYLocation(6, 5));
    board.addQueenAt(new XYLocation(7, 2));

    Assert.assertTrue(goalTest.isGoalState(board));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testBasics() {
    Assert.assertEquals(0, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(1, board.getNumberOfQueensOnBoard());
    board.addQueenAt(new XYLocation(1, 1));
    Assert.assertEquals(2, board.getNumberOfQueensOnBoard());
    Assert.assertTrue(board.queenExistsAt(new XYLocation(1, 1)));
    Assert.assertTrue(board.queenExistsAt(new XYLocation(0, 0)));
    board.moveQueen(new XYLocation(1, 1), new XYLocation(3, 3));
    Assert.assertTrue(board.queenExistsAt(new XYLocation(3, 3)));
    Assert.assertTrue(!(board.queenExistsAt(new XYLocation(1, 1))));
    Assert.assertEquals(2, board.getNumberOfQueensOnBoard());
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testCornerQueenAttack1() {

    board.addQueenAt(new XYLocation(0, 0));
    Assert.assertEquals(false,
        board.isSquareUnderAttack(new XYLocation(0, 0)));
    // queen on square not included
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(1, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(7, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(0, 7)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(1, 1)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(2, 2)));
    Assert.assertEquals(false,
        board.isSquareUnderAttack(new XYLocation(2, 1)));
    Assert.assertEquals(false,
        board.isSquareUnderAttack(new XYLocation(1, 2)));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testCornerQueenAttack2() {

    board.addQueenAt(new XYLocation(7, 7));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(0, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(7, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(0, 7)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(7, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(6, 6)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(5, 5)));
    Assert.assertEquals(false,
        board.isSquareUnderAttack(new XYLocation(6, 5)));
    Assert.assertEquals(false,
        board.isSquareUnderAttack(new XYLocation(5, 6)));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testEdgeQueenAttack() {

    board.addQueenAt(new XYLocation(0, 3));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(0, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(0, 7)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(7, 3)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(3, 0)));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(4, 7)));
  }
View Full Code Here

Examples of aima.core.util.datastructure.XYLocation

  }

  @Test
  public void testAttack2() {

    board.addQueenAt(new XYLocation(7, 0));
    Assert.assertEquals(true,
        board.isSquareUnderAttack(new XYLocation(6, 1)));
  }
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.