@Test
 public void flyToWin() throws HantoException {
   PieceLocationPair[] initialPieces = new PieceLocationPair[7];
   initialPieces[0] =
       new PieceLocationPair(
           HantoPlayerColor.BLUE, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(0, 0));
   initialPieces[1] =
       new PieceLocationPair(
           HantoPlayerColor.RED, HantoPieceType.BUTTERFLY, new ConcreteHantoCoordinate(0, 1));
   initialPieces[2] =
       new PieceLocationPair(
           HantoPlayerColor.BLUE, HantoPieceType.BUTTERFLY, new ConcreteHantoCoordinate(1, 1));
   initialPieces[3] =
       new PieceLocationPair(
           HantoPlayerColor.RED, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(0, 2));
   initialPieces[4] =
       new PieceLocationPair(
           HantoPlayerColor.BLUE, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(-1, 2));
   initialPieces[5] =
       new PieceLocationPair(
           HantoPlayerColor.RED, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(-1, 1));
   initialPieces[6] =
       new PieceLocationPair(HantoPlayerColor.BLUE, HantoPieceType.SPARROW, coord(0, 3));
   testGame.initializeBoard(initialPieces);
   testGame.setPlayerMoving(HantoPlayerColor.BLUE);
   testGame.setTurnNumber(20);
   MoveResult result =
       testGame.makeMove(
           HantoPieceType.SPARROW,
           new ConcreteHantoCoordinate(0, 3),
           new ConcreteHantoCoordinate(1, 0));
   assertEquals(MoveResult.BLUE_WINS, result);
 }
  @Test
  public void cantSlideToDest() throws HantoException {
    PieceLocationPair[] initialPieces = new PieceLocationPair[6];
    initialPieces[0] =
        new PieceLocationPair(
            HantoPlayerColor.BLUE, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(0, 0));
    initialPieces[1] =
        new PieceLocationPair(
            HantoPlayerColor.RED, HantoPieceType.BUTTERFLY, new ConcreteHantoCoordinate(1, 0));
    initialPieces[2] =
        new PieceLocationPair(
            HantoPlayerColor.BLUE, HantoPieceType.BUTTERFLY, new ConcreteHantoCoordinate(1, 1));
    initialPieces[3] =
        new PieceLocationPair(
            HantoPlayerColor.RED, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(0, 2));
    initialPieces[4] =
        new PieceLocationPair(
            HantoPlayerColor.BLUE, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(-1, 2));
    initialPieces[5] =
        new PieceLocationPair(
            HantoPlayerColor.RED, HantoPieceType.SPARROW, new ConcreteHantoCoordinate(-1, 1));
    testGame.initializeBoard(initialPieces);
    testGame.setPlayerMoving(HantoPlayerColor.BLUE);
    testGame.setTurnNumber(10);

    try {
      testGame.makeMove(
          HantoPieceType.SPARROW,
          new ConcreteHantoCoordinate(0, 0),
          new ConcreteHantoCoordinate(0, 1));
    } catch (HantoException e) {
      assertEquals("Cannot slide to destination", e.getMessage());
    }
  }
  @Test(expected = HantoException.class)
  public void attemptToPlaceAfterUsingAllButterflies() throws HantoException {
    PieceLocationPair[] initialPieces = new PieceLocationPair[1];
    initialPieces[0] =
        new PieceLocationPair(
            HantoPlayerColor.BLUE, HantoPieceType.BUTTERFLY, new ConcreteHantoCoordinate(0, 0));

    testGame.initializeBoard(initialPieces);
    testGame.setPlayerMoving(HantoPlayerColor.BLUE);
    testGame.setTurnNumber(0);
    testGame.makeMove(HantoPieceType.BUTTERFLY, null, new ConcreteHantoCoordinate(1, 0));
  }
 @Test(expected = HantoException.class)
 public void sparrowFliesToInvalidLocation()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(3);
   game.makeMove(SPARROW, makeCoordinate(-1, 0), makeCoordinate(0, 3));
 }
 @Test(expected = HantoException.class)
 public void attemptToMoveAfterGameIsOver()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
         plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
         plPair(RED, CRAB, 1, 1)
       };
   testGame.initializeBoard(board);
   testGame.setPlayerMoving(RED);
   game.makeMove(CRAB, makeCoordinate(1, 1), makeCoordinate(1, 0)); // RED wins
   game.makeMove(SPARROW, makeCoordinate(-1, 1), makeCoordinate(-1, 2));
 }
  @Test
  public void moveByFlying() throws HantoException, HantoPrematureResignationException {

    final PieceLocationPair[] board =
        new PieceLocationPair[] {
          plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
          plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
          plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
          plPair(RED, SPARROW, -2, 1)
        };
    testGame.initializeBoard(board);
    testGame.setPlayerMoving(RED);
    testGame.setTurnNumber(4);
    assertEquals(RED_WINS, game.makeMove(SPARROW, makeCoordinate(-2, 1), makeCoordinate(1, 0)));
  }
 @Test(expected = HantoException.class)
 public void crabWalksAndCreatesDisconnectedConfiguration()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, CRAB, 1, 0),
         plPair(BLUE, SPARROW, -2, 0), plPair(RED, SPARROW, 2, 0),
         plPair(BLUE, SPARROW, -3, 0)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(4);
   testGame.setPlayerMoving(RED);
   game.makeMove(CRAB, makeCoordinate(1, 0), makeCoordinate(1, -1));
 }
 @Test
 public void sparrowFliesMoreThanOneSpace()
     throws HantoException, HantoPrematureResignationException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0), plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, -1, 0), plPair(RED, SPARROW, 1, -1),
         plPair(BLUE, SPARROW, -1, 1), plPair(RED, SPARROW, 0, -1),
         plPair(RED, SPARROW, 1, 1)
       };
   testGame.initializeBoard(board);
   testGame.setTurnNumber(4);
   assertEquals(OK, game.makeMove(SPARROW, makeCoordinate(-1, 0), makeCoordinate(2, 1)));
   final HantoPiece hp = game.getPieceAt(makeCoordinate(2, 1));
   assertEquals(BLUE, hp.getColor());
   assertEquals(SPARROW, hp.getType());
 }
 @Test
 public void blueMovesSparrowUsingTestGame() throws HantoException {
   final PieceLocationPair[] board =
       new PieceLocationPair[] {
         plPair(BLUE, BUTTERFLY, 0, 0),
         plPair(RED, BUTTERFLY, 0, 1),
         plPair(BLUE, SPARROW, 0, -1),
         plPair(RED, SPARROW, 0, 2)
       };
   testGame.initializeBoard(board);
   testGame.setPlayerMoving(BLUE);
   testGame.setTurnNumber(3);
   final MoveResult mr = testGame.makeMove(SPARROW, makeCoordinate(0, -1), makeCoordinate(-1, 0));
   assertEquals(OK, mr);
   final HantoPiece piece = testGame.getPieceAt(makeCoordinate(-1, 0));
   assertEquals(BLUE, piece.getColor());
   assertEquals(SPARROW, piece.getType());
 }