Пример #1
0
def next_move(hex_message):
    noughts = get_game_noughts(hex_message)
    crosses = get_game_crosses(hex_message)

    while True:
        move = VALID_MOVES[random.randint(0, 8)]
        if noughts | move != noughts and crosses | move != crosses:
            return move
Пример #2
0
def play_nought_move(hex_message):
    move = get_move(hex_message, False)

    noughts = coder.get_game_noughts(hex_message) + move
    return coder.update_noughts(hex_message, noughts)
Пример #3
0
def check_draw(hex_message):
    noughts = get_game_noughts(hex_message)
    crosses = get_game_crosses(hex_message)
    return _check_draw(noughts, crosses)
Пример #4
0
def check_win(hex_message):
    noughts = get_game_noughts(hex_message)
    crosses = get_game_crosses(hex_message)
    if _check_position_win(noughts) or _check_position_win(crosses):
        return True
    return False
Пример #5
0
def minmax_strategy(hex_message, is_crosses):
    noughts = get_game_noughts(hex_message)
    crosses = get_game_crosses(hex_message)

    return _minmax(noughts, crosses, is_crosses, is_crosses, 0)[1]