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
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)
def check_draw(hex_message): noughts = get_game_noughts(hex_message) crosses = get_game_crosses(hex_message) return _check_draw(noughts, crosses)
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
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]