Skip to content

Instantly share code, notes, and snippets.

@tarynsauer
Created December 8, 2013 23:37
Show Gist options
  • Save tarynsauer/7865192 to your computer and use it in GitHub Desktop.
Save tarynsauer/7865192 to your computer and use it in GitHub Desktop.
def alphabeta(board, player, depth, alpha, beta)
board.open_cells.each_key do |cell|
board.add_marker(player.opponent.marker, cell)
score = (apply_minimax(board, player.opponent, cell, depth += 1, alpha, beta) / depth.to_f)
alpha = player.get_alpha(alpha, score)
beta = player.get_beta(beta, score)
board.remove_marker(cell)
break if alpha >= beta
end
player.return_value(alpha, beta)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment