minimax logic implemented