Exemplo n.º 1
0
def print_board(board):
    for row in range(board.num_rows, 0, -1):
        bump = ' ' if row <= 9 else ''
        line = []
        for col in range(1, board.num_cols + 1):
            stone = board.get(gotypes.Point(row, col))
            line.append(STONE_TO_CHAR[stone])
        print('%s%d %s' % (bump, row, ''.join(line)))
    print('    ' + '  '.join(COLS[:board.num_cols]))
Exemplo n.º 2
0
def print_board(board):
    for row in range(board.num_rows, 0, -1):
        bump = " " if row <= 9 else ""
        line = []
        for col in range(1, board.num_cols + 1):
            stone = board.get(gotypes.Point(row=row, col=col))
            line.append(STONE_TO_CHAR[stone])
        print(f'{bump}{row} {"".join(line)}')
    print('    ' + '  '.join(COLS[:board.num_cols]))
Exemplo n.º 3
0
def capture_diff(game_state):

    black_stones = 0
    white_stones = 0

    for r in range(1, game_state.board.num_rows + 1):
        for c in range(1, game_state.board.num_cols + 1):

            p = gotypes.Point(r, c)
            color = game_state.board.get(p)

            if color == gotypes.Player.black:
                black_stones += 1

            elif color == gotypes.Player.white:
                white_stones += 1

    diff = black_stones - white_stones
    if game_state.next_player == gotypes.Player.black:
        return diff

    return -1 * diff
Exemplo n.º 4
0
def point_from_coords(coords):

    col = COLS.index(coords[0]) + 1
    row = int(coords[1:])

    return gotypes.Point(row=row, col=col)