Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# if current position is game over state
if game_over(p):
CACHE[p] = ppb.LOSE
REMOTE_CACHE[p] = 0
return (ppb.LOSE, 0)
# figure out outcomes of next possible moves
possible_m = generate_moves(p)
new_p = [do_move(p, m) for m in possible_m]
outcomes = [solve(np) for np in new_p]
outcomes_w = [x for x in outcomes if x[0] == 0]
outcomes_l = [x for x in outcomes if x[0] == 1]
# if losing state exists for opposing player
if outcomes_l:
CACHE[p] = ppb.WIN
REMOTE_CACHE[p] = 1 + min(outcomes_l, key=lambda x: x[1])[1]
return (CACHE[p], REMOTE_CACHE[p])
CACHE[p] = ppb.LOSE
REMOTE_CACHE[p] = 1 + max(outcomes_w, key=lambda x: x[1])[1]
return (CACHE[p], REMOTE_CACHE[p])