def setUp(self): self.board = Board() self.board.move_if_legal("e2", "e4", "white") self.board.move_if_legal("e7", "e5", "black") self.board.move_if_legal("f1", "c4", "white") self.board.move_if_legal("b8", "c6", "black") self.board.move_if_legal("d1", "h5", "white") self.board.move_if_legal("g8", "c6", "black") self.board.move_if_legal("h5", "f7", "white")
from src.Chess2 import Board board = Board() color_to_move = "white" def switch_turn(color): if color == "white": return "black" else: return "white" print(board.display()) while not board.game_ended: move = input("Enter move in the form <from_square>,<to_square>:") from_square = move.split(",")[0] to_square = move.split(",")[1] if board.move_is_legal(from_square, to_square, color_to_move): board.move_if_legal(from_square, to_square, color_to_move) color_to_move = switch_turn(color_to_move) print("") print(board.display()) else: print("illegal move!") else: print(board.result)
def setUp(self): self.board = Board()
def setUp(self): self.board = Board() for square in square_names: setattr(self.board, square, "empty") self.board.put("a1", "white king") self.board.put("b3", "black queen")
def test_countLegalMoves_inInitialPosition(self): self.board = Board() self.assertEqual(20, self.board.count_legal_moves("white")) self.assertEqual(20, self.board.count_legal_moves("black"))
def setUp(self): self.board = Board() self.board.move_if_legal("f2", "f3", "white") self.board.move_if_legal("e7", "e5", "black") self.board.move_if_legal("g2", "g4", "white") self.board.move_if_legal("d8", "h4", "black")
def setUp(self): self.board = Board() self.board.put("white king", "a3") self.board.put("black king", "h6") self.board.free_square("e1") self.board.free_square("e8")
def setUp(self): self.board = Board() self.board.put("white king", "a3") self.board.put("black king", "h6")
def setUp(self): self.board = Board() self.board.put("white queen", "a3") self.board.put("black queen", "h6")
def setUp(self): self.board = Board() self.board.put("white knight", "e5") self.board.put("black knight", "d3")
def test_bishopCanMoveFromInitialPos(self): self.board = Board() self.board.move("e2", "e3") self.assertTrue(self.board.is_reachable("f1", "c4", "white"))
def setUp(self): self.board = Board() self.board.put("white bishop", "a3") self.board.put("black bishop", "a6")
def setUp(self): self.board = Board() self.board.put("white rook", "a3") self.board.put("black rook", "h6")