Exemple #1
0
 /**
  * Test valid <code>Plies</code> among unusable cells (user-defined). The <code>Plies</code>
  * should exclude those that end in unusable cells.
  */
 public void testPliesUnusableCenter() {
   // For white Piece with holes (unusable)
   List<int[]> unusable = new ArrayList<int[]>(2);
   unusable.add(new int[] {5, 7});
   unusable.add(new int[] {3, 3});
   Board holedBoard =
       new RectangularBoard(
           RectangularBoard.defaultLength, RectangularBoard.defaultHeight, unusable);
   Piece newKnight = new Knight(true, holedBoard);
   holedBoard.addPiece(newKnight, new int[] {4, 5});
   Set<Ply> correctPlies = new HashSet<Ply>();
   for (Ply ply : pliesAtFourFive)
     if (!ply.equals(new Move(new int[] {4, 5}, new int[] {5, 7}))
         && !ply.equals(new Move(new int[] {4, 5}, new int[] {3, 3}))) correctPlies.add(ply);
   checkPlies(correctPlies, newKnight);
 }
Exemple #2
0
 /**
  * Test valid <code>Plies</code> among <code>Piece</code>s of the same color. The <code>Plies
  * </code> should exclude those that end in a cell occupied by another <code>Piece</code> of the
  * same color.
  */
 public void testPliesSameColor() {
   // For white Piece
   Piece whitePawn = new Pawn(true, board);
   board.addPiece(whitePawn, new int[] {5, 7});
   board.addPiece(whiteKnight, new int[] {4, 5});
   Set<Ply> correctPlies = new HashSet<Ply>();
   for (Ply ply : pliesAtFourFive)
     if (!ply.equals(new Move(new int[] {4, 5}, new int[] {5, 7}))) correctPlies.add(ply);
   checkPlies(correctPlies, whiteKnight);
   // For black Piece
   board.removePiece(whitePawn);
   board.removePiece(whiteKnight);
   Piece blackPawn = new Pawn(false, board);
   board.addPiece(blackPawn, new int[] {5, 7});
   board.addPiece(blackKnight, new int[] {4, 5});
   checkPlies(correctPlies, blackKnight);
 }