Minimax and Megamax algorithm