Add minmax algorithm