Question

I understand the algorithm, as it applies to Alpha-Beta pruning. What I don't understand is since there is no way to represent ∞ in Java, on my first call to the Minimax method, what value should Alpha and Beta be to start out with? (Normally I would think you could make them -∞ and +∞). The only thing I could think of would be 0, but would that produce some unwanted results? Thanks!

Was it helpful?

Solution

It depends on the data type you're using. -∞ and +∞ simply mean the lowest and highest values possible.

If you pick int, the respective values can be Integer.MIN_VALUE and Integer.MAX_VALUE. The algorithm will work just fine.

Also, infinity can be represented in Java. If you really want to, you can use float, which has both a positive and negative infinity value. You could just use Float.POSITIVE_INFINITY and Float.NEGATIVE_INFINITY. For this algorithm,though, I'd stick with integers. Just because they're free from all possibly unexpected behavior related to rounding and precision.

OTHER TIPS

int alpha = Integer.MIN_VALUE
int beta = Integer.MAX_VALUE

Best you can do with no infinity.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top