I am doing a game tree search with alpha beta pruning in a game similar to checkers, but I am given a strict 5 second limit on determining my best move. I would like my recursion to enter the base case right before the allotted time is up.
How can I check to see how much time I have left, or maybe change a Boolean when my time is nearly done?
at each step, use
System.currentTimeMillis()to get the current time and compare that to a time that you saved before the recursion started.