Exemplo n.º 1
0
    def get_normal_board_placement(self):
        """
        Method to set the pieces properly on the chessboard for the 'normal' start position.
        This is the only method that is actually called by the program itself.
        All the other 'get_*_board_placement' methods are used solely in testing.
        """
        rank = 1
        self.__board[rank][1].piece = Rook(is_white=True)
        self.__board[rank][2].piece = Knight(is_white=True)
        self.__board[rank][3].piece = Bishop(is_white=True)
        self.__board[rank][4].piece = Queen(is_white=True)
        self.__board[rank][5].piece = King(is_white=True)
        self.__board[rank][6].piece = Bishop(is_white=True)
        self.__board[rank][7].piece = Knight(is_white=True)
        self.__board[rank][8].piece = Rook(is_white=True)

        rank = 8
        self.__board[rank][1].piece = Rook(is_white=False)
        self.__board[rank][2].piece = Knight(is_white=False)
        self.__board[rank][3].piece = Bishop(is_white=False)
        self.__board[rank][4].piece = Queen(is_white=False)
        self.__board[rank][5].piece = King(is_white=False)
        self.__board[rank][6].piece = Bishop(is_white=False)
        self.__board[rank][7].piece = Knight(is_white=False)
        self.__board[rank][8].piece = Rook(is_white=False)

        for file in range(1, 9):
            self.__board[2][file].piece = Pawn(is_white=True)
            self.__board[7][file].piece = Pawn(is_white=False)
Exemplo n.º 2
0
 def get_check_board_placement(self):
     """
     Method to set the pieces properly on the chessboard, for testing purposes.
     The next move is a position in which the computer can check the opponent.
     """
     self.__board[6][8].piece = King(is_white=False)
     self.__board[2][8].piece = Queen(is_white=False)
     self.__board[1][1].piece = King(is_white=True)
Exemplo n.º 3
0
 def get_stalemate_board_placement(self):
     """
     Method to set the pieces properly on the chessboard, for testing purposes.
     The next move for black is a position in which the computer can stalemate the opponent. (The computer will
     avoid stalemating)
     """
     self.__board[6][8].piece = King(is_white=False)
     self.__board[3][2].piece = Queen(is_white=False)
     self.__board[2][3].piece = Queen(is_white=False)
     self.__board[1][1].piece = King(is_white=True)
Exemplo n.º 4
0
 def get_failing_castling_board_placement(self):
     """
     Method to set the pieces properly on the chessboard, for testing purposes.
     The next move for white is a position in which the computer cannot castle.
     """
     self.__board[8][1].piece = Queen(is_white=False)
     self.__board[7][7].piece = Pawn(is_white=True)
     self.__board[6][7].piece = Pawn(is_white=True)
     self.__board[6][8].piece = King(is_white=False)
     self.__board[1][1].piece = Rook(is_white=True)
     self.__board[1][5].piece = King(is_white=True)