Implementation of the Minimax algorithm