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!
Asked
Active
Viewed 758 times
0

toniedzwiedz
- 17,895
- 9
- 86
- 131

Houdini
- 3,442
- 9
- 31
- 47
2 Answers
4
int alpha = Integer.MIN_VALUE
int beta = Integer.MAX_VALUE
Best you can do with no infinity.

durron597
- 31,968
- 17
- 99
- 158
4
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.

toniedzwiedz
- 17,895
- 9
- 86
- 131
-
Thanks for the answer, didnt know that about ∞ and Java! Other guy answered first :) – Houdini Nov 15 '12 at 18:03