def max_play(state, limit, oppColor=BLACKCELL):
    limit -= 1
    if is_gameover(state) or limit <= 0:
        state_value = evaluate(state, oppColor)
        return state_value
    states = obj.getNextStates(state)
    if (states):
        return max(map(lambda state: min_play(state, limit, state.whoDidThis), states))
    else:
        state.reverse_State()
        return min_play(state, limit)
Example #2
0
    step = 40
    pyautogui.click(x + (step * first), y + (step * second))


time.sleep(2)
startGame()
time.sleep(2)
playGame()
time.sleep(2)
playGame()
time.sleep(2)
playGame()

while (True):
    time.sleep(10)
    state = State(sendState(), WHITECELL)
    state = minimax(state)

    print("Next State: ")
    for row in state[0].board:
        print(row)
    print("\n")

    if (state[0].x == -1 and state[0].y == -1):
        print(f"Player didn't have a play")
        continue

    calacePosition(state[0].x, state[0].y)
    if (is_gameover(state[0])):
        break