basic minimax algorithm