1

I know i can implement this by checking for time limit before calling move generator in the negamax and quiescence functions. But I would Like to know if there is a way to run the check for time limit on a separate thread and break the execution of the loop if time limit is exceeded in C++.

John Doe
  • 149
  • 2
  • 6
  • Easiest way would be to have your timekeeping thread alter some flag that is checked every iteration of your main thread, the time save checking a single bool would be negligible vs just checking the time I fear, but i do not belie there is a better way to do this – Jay May 10 '20 at 15:15
  • Related: [How do I terminate a thread in C++11?](https://stackoverflow.com/q/12207684/509868) – anatolyg May 10 '20 at 15:32
  • @Jake but at higher depths, it may take a few seconds for a single iteration, what if the time limit is exceeded during the iteration – John Doe May 10 '20 at 15:33
  • You should check if the time limit is exceeded at each node you reach and break from the search if you have no remaining time. In Iterative deepening, you remember the best move of the previous iteration (initially the best move is a random move), and fall back to it when the time has passed. – BufferSpoofer May 25 '20 at 16:56

0 Answers0