def material_diff(board: chess.Board, queens_weights, bishops_weights, rooks_weights, knights_weights, pawns_weights): score = 0 board_string = board.__str__() white_symbols = ['Q', 'R', 'B', 'N', 'P'] black_symbols = ['q', 'r', 'b', 'n', 'p'] weights = [queens_weights, rooks_weights, bishops_weights, knights_weights, pawns_weights] for i in range(5): score += weights[i] * (AIPlayer.AIPlayer.num_of_piece(white_symbols[i], board_string) - AIPlayer.AIPlayer.num_of_piece(black_symbols[i], board_string)) return score
def make_str(board: chess.Board, is_white_on_bottom: bool) -> str: """Converts a board object into a string to be used in Markdown. Backticks are added around the string to preserve formatting. Parameters: - board: The board object. - is_white_on_bottom: Whether or not white should be on the bottom side in the string. If false, black will be on the bottom. Returns: The string made from the board. """ default_str = board.__str__() replaced_str = replace_with_unicode(default_str) replaced_and_guided_str = guide_with_numbers(replaced_str) properly_flipped_str = (replaced_and_guided_str if is_white_on_bottom else replaced_and_guided_str[::-1]) trimmed_str = trim_whitespace_before_newline(properly_flipped_str) monospaced_str = '```\n{}\n```'.format(trimmed_str) return monospaced_str