def test_move_checks_king(self): cases = [ { "name": "move_checks_king", "layout": { (6, 2): King(Game.WHITE), (5, 2): Queen(Game.WHITE), (3, 2): Rook(Game.BLACK) }, "formatted_string": "QC3D3", "expected_move_checks_king": True }, { "name": "move_doesnt_check_king", "layout": { (6, 3): King(Game.WHITE), (5, 2): Queen(Game.WHITE), (3, 2): Rook(Game.BLACK) }, "formatted_string": "QC3D3", "expected_move_checks_king": False } ] for case in cases: with self.subTest(case["name"]): board = Board(case["layout"]) board.create_move(case["formatted_string"]) actual_move_checks_king = board.move_checks_king() self.assertEqual(case["expected_move_checks_king"], actual_move_checks_king)
def set_new_game(self): """ Initializes pieces for a new chess game. Uses two for loops and if/else statements to set the pieces. """ board = [] A, B, C, D, E, F, G, H = range( 8 ), range(8), range(8), range(8), range(8), range(8), range(8), range( 8 ) # Feels unpythonic but can't do A = B = C = ... = range(8) since lists are mutable board.extend([A, B, C, D, E, F, G, H]) for row in xrange(8): for col in xrange(8): if col == 1: board[row][col] = Pawn(False, 'White') elif col == 6: board[row][col] = Pawn(False, 'Black') elif col in range(2, 7): board[row][col] = Piece() elif col == 0: if row == 0 or row == 7: board[row][col] = Rook(False, 'White') elif row == 1 or row == 6: board[row][col] = Knight(False, 'White') elif row == 2 or row == 5: board[row][col] = Bishop(False, 'White') elif row == 3: board[row][col] = Queen(False, 'White') else: board[row][col] = King(False, 'White') else: if row == 0 or row == 7: board[row][col] = Rook(False, 'Black') elif row == 1 or row == 6: board[row][col] = Knight(False, 'Black') elif row == 2 or row == 5: board[row][col] = Bishop(False, 'Black') elif row == 3: board[row][col] = Queen(False, 'Black') else: board[row][col] = King(False, 'Black') return board
def test_queen_upper_vertical_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_upper_vertical_attack_points = {Point(1, 4), Point(0, 4)} actual_upper_vertical_attack_points = queen._get_upper_vertical_attack_points( ) self.assertEqual(expected_upper_vertical_attack_points, actual_upper_vertical_attack_points)
def test_queen_lower_right_diagonal_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_lower_right_diagonal_attack_points = { Point(3, 5), Point(4, 6), Point(5, 7) } actual_lower_right_diagonal_attack_points = queen._get_lower_right_diagonal_attack_points( ) self.assertEqual(expected_lower_right_diagonal_attack_points, actual_lower_right_diagonal_attack_points)
def test_queen_upper_right_diagonal_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_upper_right_diagonal_attack_points = { Point(1, 5), Point(0, 6) } actual_upper_right_diagonal_attack_points = queen._get_upper_right_diagonal_attack_points( ) self.assertEqual(expected_upper_right_diagonal_attack_points, actual_upper_right_diagonal_attack_points)
def test_queen_right_horizonal_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_right_horizontal_attack_points = { Point(2, 5), Point(2, 6), Point(2, 7) } actual_right_horizontal_attack_points = queen._get_right_horizontal_attack_points( ) self.assertEqual(expected_right_horizontal_attack_points, actual_right_horizontal_attack_points)
def test_queen_left_horizonal_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_left_horizontal_attack_points = { Point(2, 3), Point(2, 2), Point(2, 1), Point(2, 0) } actual_left_horizontal_attack_points = queen._get_left_horizontal_attack_points( ) self.assertEqual(expected_left_horizontal_attack_points, actual_left_horizontal_attack_points)
def test_queen_lower_left_diagonal_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_lower_left_diagonal_attack_points = { Point(3, 3), Point(4, 2), Point(5, 1), Point(6, 0) } actual_lower_left_diagonal_attack_points = queen._get_lower_left_diagonal_attack_points( ) self.assertEqual(expected_lower_left_diagonal_attack_points, actual_lower_left_diagonal_attack_points)
def test_player_get_all_attack_points(self): expected_player_all_attack_points = set() queens = {Queen(Point(0, 0)), Queen(Point(7, 7))} player = Player() for queen in queens: player.add_piece(queen) expected_player_all_attack_points = expected_player_all_attack_points | queen.get_attack_points( ) actual_player_all_attack_points = player.get_all_attack_points() self.assertEqual(expected_player_all_attack_points, actual_player_all_attack_points)
def check_promotion(self): for line in self.get_board().board: for square in (line[0], line[-1]): piece = square.get_piece() if square.get_number() == '8' and isinstance( piece, Pawn) and piece.get_color() == WHITE: square.set_square_free() self.get_board().set_piece_on_square( square.get_letter(), square.get_number(), Queen(WHITE)) elif square.number == '1' and isinstance( piece, Pawn) and piece.get_color() == BLACK: square.set_square_free() self.get_board().set_piece_on_square( square.get_letter(), square.get_number(), Queen(BLACK))
def test_queen_lower_vertical_attack_points_2_4(self): queen = Queen(Point(2, 4)) expected_lower_vertical_attack_points = { Point(3, 4), Point(4, 4), Point(5, 4), Point(6, 4), Point(7, 4) } actual_lower_vertical_attack_points = queen._get_lower_vertical_attack_points( ) self.assertEqual(expected_lower_vertical_attack_points, actual_lower_vertical_attack_points)
def test_can_move_king(self): cases = [ { "name": "can_move_king", "layout": { (3, 0): King(Game.BLACK), (6, 0): Rook(Game.WHITE) }, "formatted_string": "RB2A2", "expected_can_move_king": True }, { "name": "cannot_move_king", "layout": { (3, 0): King(Game.BLACK), (7, 1): Queen(Game.WHITE), (6, 0): Rook(Game.WHITE) }, "formatted_string": "RB2A2", "expected_can_move_king": False } ] for case in cases: with self.subTest(case["name"]): board = Board(case["layout"]) board.create_move(case["formatted_string"]) actual_can_move_king = board.can_move_king() self.assertEqual(case["expected_can_move_king"], actual_can_move_king)
def new_game(self): pieces = list() self.pieces = list() # Pawn initialisation for i in range(1, 9): if self.color == "black": pieces.append(Pawn(i, 7)) if self.color == "white": pieces.append(Pawn(i, 2)) # Rook initialisation if self.color == "black": pieces.append(Rook(1, 8)) pieces.append(Rook(8, 8)) if self.color == "white": pieces.append(Rook(1, 1)) pieces.append(Rook(8, 1)) # Knight initialisation if self.color == "black": pieces.append(Knight(2, 8)) pieces.append(Knight(7, 8)) if self.color == "white": pieces.append(Knight(2, 1)) pieces.append(Knight(7, 1)) # Bishop initialisation if self.color == "black": pieces.append(Bishop(3, 8)) pieces.append(Bishop(6, 8)) if self.color == "white": pieces.append(Bishop(3, 1)) pieces.append(Bishop(6, 1)) # Queen initialisation if self.color == "black": pieces.append(Queen(4, 8)) if self.color == "white": pieces.append(Queen(4, 1)) # King initialisation if self.color == "black": pieces.append(King(5, 8)) if self.color == "white": pieces.append(King(5, 1)) self.pieces = pieces
def initialize_starting_board(self): for letter in letters: self.set_piece_on_square(letter, 7, Pawn(BLACK)) self.set_piece_on_square(letter, 2, Pawn(WHITE)) for letter in ['a', 'h']: self.set_piece_on_square(letter, 1, Bishop(WHITE)) self.set_piece_on_square(letter, 8, Bishop(BLACK)) for letter in ['b', 'g']: self.set_piece_on_square(letter, 1, Knight(WHITE)) self.set_piece_on_square(letter, 8, Knight(BLACK)) for letter in ['c', 'f']: self.set_piece_on_square(letter, 1, Rook(WHITE)) self.set_piece_on_square(letter, 8, Rook(BLACK)) self.set_piece_on_square('d', 1, Queen(WHITE)) self.set_piece_on_square('e', 8, Queen(BLACK)) self.set_piece_on_square('e', 1, King(WHITE)) self.set_piece_on_square('d', 8, King(BLACK))
def checkPromotion(self, player): if player.color == "black": y = 1 elif player.color == "white": y = 8 if self.positions.y == y: player.pieces[player.getPieceIndex(self.positions)] = Queen( self.positions.x, y)
def test_player_get_piece_points(self): expected_player_piece_points = {Point(0, 0), Point(1, 2), Point(2, 4)} player = Player() for point in expected_player_piece_points: player.add_piece(Queen(point)) actual_player_piece_points = player.get_piece_points() self.assertEqual(expected_player_piece_points, actual_player_piece_points)
def __init__(self, layout: Dict[Tuple[int], Piece] = {}) -> None: default_layout = { (7, 0): Rook(Game.WHITE), (7, 1): Knight(Game.WHITE), (7, 2): Bishop(Game.WHITE), (7, 3): Queen(Game.WHITE), (7, 4): King(Game.WHITE), (7, 5): Bishop(Game.WHITE), (7, 6): Knight(Game.WHITE), (7, 7): Rook(Game.WHITE), (6, 0): Pawn(Game.WHITE), (6, 1): Pawn(Game.WHITE), (6, 2): Pawn(Game.WHITE), (6, 3): Pawn(Game.WHITE), (6, 4): Pawn(Game.WHITE), (6, 5): Pawn(Game.WHITE), (6, 6): Pawn(Game.WHITE), (6, 7): Pawn(Game.WHITE), (1, 0): Pawn(Game.BLACK), (1, 1): Pawn(Game.BLACK), (1, 2): Pawn(Game.BLACK), (1, 3): Pawn(Game.BLACK), (1, 4): Pawn(Game.BLACK), (1, 5): Pawn(Game.BLACK), (1, 6): Pawn(Game.BLACK), (1, 7): Pawn(Game.BLACK), (0, 0): Rook(Game.BLACK), (0, 1): Knight(Game.BLACK), (0, 2): Bishop(Game.BLACK), (0, 3): Queen(Game.BLACK), (0, 4): King(Game.BLACK), (0, 5): Bishop(Game.BLACK), (0, 6): Knight(Game.BLACK), (0, 7): Rook(Game.BLACK) } self._layout = layout or default_layout self._layout_memento = {} self._move = None self._move_memento = None self._moves = []
def test_can_move(self): layout = { (6, 3): King(Game.WHITE), (5, 2): Queen(Game.WHITE), (3, 2): Rook(Game.BLACK) } board = Board(layout) move_string = "QC3D3" expected_can_move = True actual_can_move = board.can_move(move_string) self.assertEqual(expected_can_move, actual_can_move)
def _get_piece_from_formatted_string(self, formatted_string: str) -> Piece: piece_string = formatted_string[0] if Game.PAWN_STRING == piece_string: return Pawn(self._color) elif Game.KNIGHT_STRING == piece_string: return Knight(self._color) elif Game.BISHOP_STRING == piece_string: return Bishop(self._color) elif Game.ROOK_STRING == piece_string: return Rook(self._color) elif Game.QUEEN_STRING == piece_string: return Queen(self._color) else: return King(self._color)
def test_king_checkmate(self): layout = { (3, 0): King(Game.BLACK), (6, 0): Rook(Game.WHITE), (7, 1): Queen(Game.WHITE) } board = Board(layout) formatted_string = "RB2A2" board.create_move(formatted_string) expected_checkmate = True actual_checkmate = board.king_checkmate() self.assertEqual(expected_checkmate, actual_checkmate)
def eight_queens_strategy_step(self): if 0 < len(self._seen_eight_queens): return if 8 == len(self._player.get_piece_points()): seen_eight_queens.add(self._player.get_piece_points()) return for row in range(Board.ROWS): for column in range(Board.COLUMNS): point = Point(row, column) if point in self._player.get_piece_points( ) or point in self._player.get_all_attack_points(): continue queen = Queen(Point(row, column)) self._player.add_piece(queen) self.eight_queens_strategy_step() self._player.remove_piece(queen)
def test_can_block_king_attacker(self): cases = [ { "name": "can_block_king_attacker_up_vertical", "layout": { (3, 3): King(Game.BLACK), (0, 3): Rook(Game.WHITE), (1, 4): Queen(Game.BLACK) }, "formatted_string": "RC8D8", "expected_can_block": True }, { "name": "can_block_king_attacker_up_right_diagonal", "layout": { (3, 3): King(Game.BLACK), (0, 6): Bishop(Game.WHITE), (1, 4): Queen(Game.BLACK) }, "formatted_string": "BH7G8", "expected_can_block": True }, { "name": "can_block_king_attacker_right_horizontal", "layout": { (3, 3): King(Game.BLACK), (3, 6): Rook(Game.WHITE), (1, 4): Queen(Game.BLACK) }, "formatted_string": "RG6G5", "expected_can_block": True }, { "name": "can_block_king_attacker_down_right_diagonal", "layout": { (3, 3): King(Game.BLACK), (6, 6): Bishop(Game.WHITE), (1, 4): Queen(Game.BLACK) }, "formatted_string": "BF1G2", "expected_can_block": True }, { "name": "can_block_king_attacker_down_vertical", "layout": { (3, 3): King(Game.BLACK), (6, 3): Rook(Game.WHITE), (5, 2): Queen(Game.BLACK) }, "formatted_string": "RB2A2", "expected_can_block": True }, { "name": "can_block_king_attacker_down_left_diagonal", "layout": { (3, 3): King(Game.BLACK), (6, 0): Bishop(Game.WHITE), (5, 2): Queen(Game.BLACK) }, "formatted_string": "BB1A2", "expected_can_block": True }, { "name": "can_block_king_attacker_left_horizontal", "layout": { (3, 3): King(Game.BLACK), (3, 0): Rook(Game.WHITE), (5, 2): Queen(Game.BLACK) }, "formatted_string": "RA4A5", "expected_can_block": True }, { "name": "can_block_king_attacker_up_left_diagonal", "layout": { (3, 3): King(Game.BLACK), (0, 0): Queen(Game.WHITE), (5, 2): Queen(Game.BLACK) }, "formatted_string": "QA7A8", "expected_can_block": True }, { "name": "cannot_block_king_attacker", "layout": { (3, 0): King(Game.BLACK), (5, 2): Bishop(Game.BLACK), (6, 0): Rook(Game.WHITE) }, "formatted_string": "RB2A2", "expected_can_block": False }, { "name": "cannot_block_king_attacker_makes_check", "layout": { (3, 0): King(Game.BLACK), (5, 2): Knight(Game.BLACK), (6, 0): Rook(Game.WHITE), (6, 3): Bishop(Game.WHITE) }, "formatted_string": "RB2A2", "expected_can_block": False }, { "name": "cannot_block_king_attacker_two_attackers", "layout": { (3, 0): King(Game.BLACK), (5, 2): Knight(Game.BLACK), (6, 0): Rook(Game.WHITE), (4, 2): Knight(Game.WHITE) }, "formatted_string": "NA3C4", "expected_can_block": False } ] for case in cases: with self.subTest(case["name"]): board = Board(case["layout"]) board.create_move(case["formatted_string"]) actual_can_block = board.can_block_king_attacker() self.assertEqual(case["expected_can_block"], actual_can_block)
def test_board_get_destinations_from_origin(self): cases = [ { "name": "white_pawn_first_move", "origin": (6, 1), "layout": { (6, 1): Pawn(Game.WHITE) }, "expected_destinations": {(5, 1), (4, 1)} }, { "name": "white_pawn_not_first_move", "origin": (5, 1), "layout": { (5, 1): Pawn(Game.WHITE) }, "expected_destinations": {(4, 1)} }, { "name": "white_pawn_no_queen_promotion", "origin": (0, 1), "layout": { (0, 1): Pawn(Game.WHITE) }, "expected_destinations": set() }, { "name": "white_pawn_attack", "origin": (6, 1), "layout": { (6, 1): Pawn(Game.WHITE), (5, 0): Pawn(Game.BLACK), (5, 2): Pawn(Game.BLACK) }, "expected_destinations": {(5, 1), (4, 1), (5, 0), (5, 2)} }, { "name": "white_pawn_no_attack", "origin": (6, 1), "layout": { (6, 1): Pawn(Game.WHITE), (5, 0): Pawn(Game.WHITE), (5, 2): Pawn(Game.WHITE) }, "expected_destinations": {(5, 1), (4, 1)} }, { "name": "black_pawn_first_move", "origin": (1, 1), "layout": { (1, 1): Pawn(Game.BLACK) }, "expected_destinations": {(2, 1), (3, 1)} }, { "name": "black_pawn_not_first_move", "origin": (2, 1), "layout": { (2, 1): Pawn(Game.BLACK) }, "expected_destinations": {(3, 1)} }, { "name": "black_pawn_attack", "origin": (1, 1), "layout": { (1, 1): Pawn(Game.BLACK), (2, 0): Pawn(Game.WHITE), (2, 2): Pawn(Game.WHITE) }, "expected_destinations": {(2, 1), (3, 1), (2, 0), (2, 2)} }, { "name": "black_pawn_no_attack", "origin": (1, 1), "layout": { (1, 1): Pawn(Game.BLACK), (2, 0): Pawn(Game.BLACK), (2, 2): Pawn(Game.BLACK) }, "expected_destinations": {(2, 1), (3, 1)} }, { "name": "knight", "origin": (4, 3), "layout": { (4, 3): Knight(Game.WHITE) }, "expected_destinations": {(2, 2), (2, 4), (3, 5), (5, 5), (6, 4), (6, 2), (5, 1), (3, 1)} }, { "name": "knight_and_pieces", "origin": (4, 3), "layout": { (4, 3): Knight(Game.WHITE), (3, 1): Pawn(Game.BLACK), (3, 5): Pawn(Game.BLACK), (2, 2): Pawn(Game.WHITE), (2, 4): Pawn(Game.WHITE) }, "expected_destinations": {(3, 5), (5, 5), (6, 4), (6, 2), (5, 1), (3, 1)} }, { "name": "knight_board_edge", "origin": (7, 1), "layout": { (7, 1): Knight(Game.WHITE) }, "expected_destinations": {(5, 0), (5, 2), (6, 3)} }, { "name": "bishop", "origin": (4, 2), "layout": { (4, 2): Bishop(Game.WHITE) }, "expected_destinations": {(3, 3), (2, 4), (1, 5), (0, 6), (5, 3), (6, 4), (7, 5), (5, 1), (6, 0), (3, 1), (2, 0)} }, { "name": "bishop_and_pieces", "origin": (4, 2), "layout": { (4, 2): Bishop(Game.WHITE), (2, 0): Pawn(Game.WHITE), (2, 4): Pawn(Game.WHITE), (6, 4): Pawn(Game.BLACK), (6, 0): Pawn(Game.BLACK) }, "expected_destinations": {(3, 1), (3, 3), (5, 1), (5, 3), (6, 0), (6, 4)} }, { "name": "rook", "origin": (4, 2), "layout": { (4, 2): Rook(Game.WHITE) }, "expected_destinations": {(3, 2), (2, 2), (1, 2), (0, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 2), (6, 2), (7, 2), (4, 1), (4, 0)} }, { "name": "rook_and_pieces", "origin": (4, 2), "layout": { (4, 2): Rook(Game.WHITE), (2, 2): Pawn(Game.WHITE), (4, 4): Pawn(Game.WHITE), (6, 2): Pawn(Game.BLACK), (4, 0): Pawn(Game.BLACK) }, "expected_destinations": {(3, 2), (4, 3), (5, 2), (6, 2), (4, 1), (4, 0)} }, { "name": "queen", "origin": (4, 2), "layout": { (4, 2): Queen(Game.WHITE) }, "expected_destinations": {(3, 3), (2, 4), (1, 5), (0, 6), (5, 3), (6, 4), (7, 5), (5, 1), (6, 0), (3, 1), (2, 0), (3, 2), (2, 2), (1, 2), (0, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7), (5, 2), (6, 2), (7, 2), (4, 1), (4, 0)} }, { "name": "queen_and_pieces", "origin": (4, 2), "layout": { (4, 2): Queen(Game.WHITE), (2, 0): Pawn(Game.WHITE), (2, 2): Pawn(Game.WHITE), (2, 4): Pawn(Game.WHITE), (4, 4): Pawn(Game.WHITE), (6, 4): Pawn(Game.BLACK), (6, 2): Pawn(Game.BLACK), (6, 0): Pawn(Game.BLACK), (4, 0): Pawn(Game.BLACK) }, "expected_destinations": {(3, 1), (3, 2), (3, 3), (4, 3), (5, 3), (6, 4), (5, 2), (6, 2), (5, 1), (6, 0), (4, 1), (4, 0)} }, { "name": "king", "origin": (4, 2), "layout": { (4, 2): King(Game.WHITE) }, "expected_destinations": {(3, 2), (3, 3), (4, 3), (5, 3), (5, 2), (5, 1), (4, 1), (3, 1)} }, { "name": "king_and_pieces", "origin": (4, 2), "layout": { (4, 2): King(Game.WHITE), (3, 1): Knight(Game.WHITE), (3, 2): Knight(Game.WHITE), (3, 3): Knight(Game.WHITE), (4, 3): Knight(Game.WHITE), (5, 3): Knight(Game.BLACK), (5, 2): Knight(Game.BLACK), (5, 1): Knight(Game.BLACK), (4, 1): Knight(Game.BLACK) }, "expected_destinations": {(5, 3), (5, 2), (5, 1), (4, 1)} } ] for case in cases: with self.subTest(case["name"]): board = Board(case["layout"]) actual_destinations = board._get_destinations_from_origin(case["origin"]) self.assertEqual(case["expected_destinations"], actual_destinations)
whitePawn6 = Pawn("whitepawn.png", 6, 6, False, True, "white") whitePawnImage6 = pygame.image.load(whitePawn6.getImage()) whitePawnImage6 = pygame.transform.scale(whitePawnImage6, (50,50)) board.update(6,6,True) whitePawn7 = Pawn("whitepawn.png", 6, 7, False, True, "white") whitePawnImage7 = pygame.image.load(whitePawn7.getImage()) whitePawnImage7 = pygame.transform.scale(whitePawnImage7, (50,50)) board.update(6,7,True) blackKing = King("blackking.png",0, 4, False, True, "black") blackKingImage = pygame.image.load(blackKing.getImage()) blackKingImage = pygame.transform.scale(blackKingImage, (50,50)) board.update(0,4,True) blackQueen = Queen("blackqueen.png", 0, 3, False, True, "black") blackQueenImage = pygame.image.load(blackQueen.getImage()) blackQueenImage = pygame.transform.scale(blackQueenImage, (50, 50)) board.update(0,3,True) whiteKing = King("whiteking.png",7, 4, False, True, "white") whiteKingImage = pygame.image.load(whiteKing.getImage()) whiteKingImage = pygame.transform.scale(whiteKingImage, (50,50)) board.update(7,4,True) whiteQueen = Queen("whitequeen.png", 7, 3, False, True, "white") whiteQueenImage = pygame.image.load(whiteQueen.getImage()) whiteQueenImage = pygame.transform.scale(whiteQueenImage, (50, 50)) board.update(7,3,True) blackBishopL = Bishop("blackbishop.png",0, 2, False, True, "black")
""" Created on Mon Feb 10 23:52:45 2020 sudoku yap @author: ozan """ from Board import Board from Piece import Piece, Pawn, Rook, Knight, Bishop, Queen, King import chessAI # board = Board() # board.matrix[0][0] = Rook(0, 0, 0) board.matrix[0][1] = Knight(0, 0, 1) board.matrix[0][2] = Bishop(0, 0, 2) board.matrix[0][3] = Queen(0, 0, 3) board.matrix[0][4] = King(0, 0, 4) board.matrix[0][5] = Bishop(0, 0, 5) board.matrix[0][6] = Knight(0, 0, 6) board.matrix[0][7] = Rook(0, 0, 7) # board.matrix[1][0] = Pawn(0, 1, 0) board.matrix[1][1] = Pawn(0, 1, 1) board.matrix[1][2] = Pawn(0, 1, 2) board.matrix[1][3] = Pawn(0, 1, 3) board.matrix[1][4] = Pawn(0, 1, 4) board.matrix[1][5] = Pawn(0, 1, 5) board.matrix[1][6] = Pawn(0, 1, 6) board.matrix[1][7] = Pawn(0, 1, 7) # board.matrix[7][0] = Rook(1, 0, 0)