implemented minimax tree