Exemplo n.º 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
Exemplo n.º 2
0
def play_cross_move(hex_message):
    move = get_move(hex_message, True)

    crosses = coder.get_game_crosses(hex_message) + move
    return coder.update_crosses(hex_message, crosses)
Exemplo n.º 3
0
def check_draw(hex_message):
    noughts = get_game_noughts(hex_message)
    crosses = get_game_crosses(hex_message)
    return _check_draw(noughts, crosses)
Exemplo n.º 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
Exemplo n.º 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]