Ejemplo n.º 1
0
def print_board(game: othello_console.Othello) -> None:
    """ Prints a board in the form of 2D list """
    print("B: {}  W: {}".format(add_pieces(game, "B"), add_pieces(game, "W")))
    for row in range(game.get_rows()):
        for col in range(game.get_cols()):
            print(game.get_board()[row][col], end=" ")
        print()
Ejemplo n.º 2
0
def add_pieces(game: othello_console.Othello, piece: str) -> int:
    """ Totals the number of pieces of B/W given the piece type as a str """
    sum = 0
    for row in range(game.get_rows()):
        for col in range(game.get_cols()):
            board_piece = game.get_board()[row][col]
            if board_piece == piece:
                sum += 1
    return sum