Gomoku: limited time to search

I am creating a program in C Gomoku . He uses Minimax to choose the best move. However, he can only search for the best move for 10 seconds. How to determine when my search function spent 10 seconds of searching. If you could provide me with either an example or a link to documentation that would be highly appreciated.

+3
source share
5 answers
#include <time.h>
time_t start_time = time(NULL);
while (((int)(time(NULL) - start_time)) < 10) {
  //search
}

That is what comes to mind. He has not been tested.

+5
source

, . Minmax, . Minmax . , Iterative Deepening Minmax a Sentinel Value, .

+3

!. - , , . 30 , , , 1 , !

- , , , , ! ( -) . , .

+3

alarm. okWereDoneNow , reset.

, . , . , - . - !

+1

time() time.h. , . , difftime() .

- .

++, - C.

0

Source: https://habr.com/ru/post/1769912/


All Articles