public void KingValidMovesTest() { Board board = new Board(); var piece = new PieceKing(PieceColor.White); board.LoadPiece("a1", piece); piece.CalculateValidMoves(); Assert.AreEqual(3, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b1")); Assert.IsTrue(piece.IsValidMove("a2")); Assert.IsTrue(piece.IsValidMove("b2")); board.ClearPieces(); board.LoadPiece("a8", piece); piece.CalculateValidMoves(); Assert.AreEqual(3, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a7")); Assert.IsTrue(piece.IsValidMove("b7")); Assert.IsTrue(piece.IsValidMove("b8")); board.ClearPieces(); board.LoadPiece("h1", piece); piece.CalculateValidMoves(); Assert.AreEqual(3, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("h2")); Assert.IsTrue(piece.IsValidMove("g1")); Assert.IsTrue(piece.IsValidMove("g2")); board.ClearPieces(); board.LoadPiece("h8", piece); piece.CalculateValidMoves(); Assert.AreEqual(3, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("g8")); Assert.IsTrue(piece.IsValidMove("g7")); Assert.IsTrue(piece.IsValidMove("h7")); board.ClearPieces(); board.LoadPiece("d4", piece); piece.CalculateValidMoves(); Assert.AreEqual(3 + 2 + 3, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("c3")); Assert.IsTrue(piece.IsValidMove("d3")); Assert.IsTrue(piece.IsValidMove("e3")); Assert.IsTrue(piece.IsValidMove("c4")); Assert.IsTrue(piece.IsValidMove("e4")); Assert.IsTrue(piece.IsValidMove("c5")); Assert.IsTrue(piece.IsValidMove("d5")); Assert.IsTrue(piece.IsValidMove("e5")); }
public void RookBasicValidMovesTest() { Board board = new Board(); PieceRook piece = new PieceRook(PieceColor.White); board.LoadPiece("a1", piece); piece.CalculateValidMoves(); Assert.AreEqual(14, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a8")); Assert.IsTrue(piece.IsValidMove("h1")); board.ClearPieces(); board.LoadPiece("h8", piece); piece.CalculateValidMoves(); Assert.AreEqual(14, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a8")); Assert.IsTrue(piece.IsValidMove("h1")); board.ClearPieces(); board.LoadPiece("d4", piece); piece.CalculateValidMoves(); Assert.AreEqual(14, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("d1")); Assert.IsTrue(piece.IsValidMove("d8")); Assert.IsTrue(piece.IsValidMove("a4")); Assert.IsTrue(piece.IsValidMove("h4")); }
public void QueenBasicValidLateralMovesTest() { Board board = new Board(); var piece = new PieceQueen(PieceColor.White); board.LoadPiece("a1", piece); piece.CalculateValidMoves(); Assert.AreEqual(21, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a8")); Assert.IsTrue(piece.IsValidMove("h1")); board.ClearPieces(); board.LoadPiece("h8", piece); piece.CalculateValidMoves(); Assert.AreEqual(21, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a8")); Assert.IsTrue(piece.IsValidMove("h1")); board.ClearPieces(); board.LoadPiece("d4", piece); piece.CalculateValidMoves(); Assert.AreEqual(13 + 14, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("d1")); Assert.IsTrue(piece.IsValidMove("d8")); Assert.IsTrue(piece.IsValidMove("a4")); Assert.IsTrue(piece.IsValidMove("h4")); }
public void KnightValidMovesTest() { Board board = new Board(); var piece = new PieceKnight(PieceColor.White); board.LoadPiece("a1", piece); piece.CalculateValidMoves(); Assert.AreEqual(2, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b3")); Assert.IsTrue(piece.IsValidMove("c2")); board.ClearPieces(); board.LoadPiece("a8", piece); piece.CalculateValidMoves(); Assert.AreEqual(2, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b6")); Assert.IsTrue(piece.IsValidMove("c7")); board.ClearPieces(); board.LoadPiece("h1", piece); piece.CalculateValidMoves(); Assert.AreEqual(2, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("f2")); Assert.IsTrue(piece.IsValidMove("g3")); board.ClearPieces(); board.LoadPiece("h8", piece); piece.CalculateValidMoves(); Assert.AreEqual(2, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("g6")); Assert.IsTrue(piece.IsValidMove("f7")); board.ClearPieces(); board.LoadPiece("d4", piece); piece.CalculateValidMoves(); Assert.AreEqual(8, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("c2")); Assert.IsTrue(piece.IsValidMove("e2")); Assert.IsTrue(piece.IsValidMove("b3")); Assert.IsTrue(piece.IsValidMove("f3")); Assert.IsTrue(piece.IsValidMove("b5")); Assert.IsTrue(piece.IsValidMove("f5")); Assert.IsTrue(piece.IsValidMove("c6")); Assert.IsTrue(piece.IsValidMove("e6")); }
public void BishopBasicValidMovesTest() { Board board = new Board(); var piece = new PieceBishop(PieceColor.White); board.LoadPiece("a1", piece); piece.CalculateValidMoves(); Assert.AreEqual(7, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b2")); Assert.IsTrue(piece.IsValidMove("h8")); board.ClearPieces(); board.LoadPiece("a8", piece); piece.CalculateValidMoves(); Assert.AreEqual(7, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b7")); Assert.IsTrue(piece.IsValidMove("h1")); board.ClearPieces(); board.LoadPiece("h1", piece); piece.CalculateValidMoves(); Assert.AreEqual(7, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b7")); Assert.IsTrue(piece.IsValidMove("a8")); board.ClearPieces(); board.LoadPiece("h8", piece); piece.CalculateValidMoves(); Assert.AreEqual(7, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("b2")); Assert.IsTrue(piece.IsValidMove("a1")); board.ClearPieces(); board.LoadPiece("d4", piece); piece.CalculateValidMoves(); Assert.AreEqual(13, piece.GetValidMovesCount()); Assert.IsTrue(piece.IsValidMove("a1")); Assert.IsTrue(piece.IsValidMove("h8")); Assert.IsTrue(piece.IsValidMove("a7")); Assert.IsTrue(piece.IsValidMove("g1")); }