def test_blocked_moves(self): position = [[None, None, None, (HORSE, WHITE), None, None, None, None], [None, (HORSE, WHITE), None, None, None, None, None, None], [None, None, None, (HORSE, WHITE), None, None, None, None], [None, None, (HORSE, WHITE), None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None]] chess_position = ChessPosition(position, 3) moves = chess_position._get_knight_moves(position[1][1], 1, 1) self.assertEquals(len(moves), 1, moves) move = moves[0] self.assertExistsPiece(move, (HORSE, WHITE), 3, 0)
def test_capture_moves(self): position = [ [None, None, None, (HORSE, WHITE), None, None, None, None], [None, (HORSE, WHITE), None, None, None, None, None, None], [None, None, None, (HORSE, WHITE), None, None, None, None], [(HORSE, BLACK), None, (HORSE, WHITE), None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None]] chess_position = ChessPosition(position, 3) moves = chess_position._get_knight_moves(position[1][1], 1, 1) self.assertEquals(len(moves), 1, moves) move = moves[0] self.assertExistsPiece(move, (HORSE, WHITE), 3, 0)
def test_middle_knight_moves(self): position = [[None, None, None, None, None, None, None, None], [None, (HORSE, WHITE), None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None]] chess_position = ChessPosition(position, 3) moves = chess_position._get_knight_moves(position[1][1], 1, 1) self.assertEquals(len(moves), 4, moves) move = moves[0] self.assertOnlyPiece(move, (HORSE, WHITE), 3, 2) move = moves[1] self.assertOnlyPiece(move, (HORSE, WHITE), 2, 3) move = moves[2] self.assertOnlyPiece(move, (HORSE, WHITE), 0, 3) move = moves[3] self.assertOnlyPiece(move, (HORSE, WHITE), 3, 0)
def test_middle_knight_moves(self): position = [ [None, None, None, None, None, None, None, None], [None, (HORSE, WHITE), None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None], [None, None, None, None, None, None, None, None]] chess_position = ChessPosition(position, 3) moves = chess_position._get_knight_moves(position[1][1], 1, 1) self.assertEquals(len(moves), 4, moves) move = moves[0] self.assertOnlyPiece(move, (HORSE, WHITE), 3, 2) move = moves[1] self.assertOnlyPiece(move, (HORSE, WHITE), 2, 3) move = moves[2] self.assertOnlyPiece(move, (HORSE, WHITE), 0, 3) move = moves[3] self.assertOnlyPiece(move, (HORSE, WHITE), 3, 0)