1 #ifndef ZZGO_TIMEINFO_H
2 #define ZZGO_TIMEINFO_H
4 /* Time-keeping information about time to spend on the next move and/or
7 /* Note that some ways of specifying time (TD_GAMES) may not make sense
15 /* For how long we can spend the time? */
17 TT_NULL
, // No time limit. Other structure elements are undef.
18 TT_MOVE
, // Time for the next move.
19 TT_TOTAL
, // Time for the rest of the game.
21 /* How are we counting the time? */
23 TD_GAMES
, // Fixed number of simulations to perform.
24 TD_WALLTIME
, // Wall time to spend performing simulations.
27 int games
; // TD_GAMES
28 struct { // TD_WALLTIME
29 /* Recommended wall time for next move or game (seconds). Does not
30 * include net lag. Play asap if 0. */
31 double recommended_time
;
33 /* Absolute time at which our timer started for current move, 0 if
34 * not yet known. The engine always sees > 0. */
40 /* Parse time information provided in custom format:
41 * =NUM - fixed number of simulations per move
42 * NUM - number of seconds to spend per move (can be float)
43 * _NUM - number of seconds to spend per game
45 * Returns false on parse error. */
46 bool time_parse(struct time_info
*ti
, char *s
);
48 /* Start our timer. kgs does this (correctly) on "play" not "genmove"
49 * unless we are making the first move of the game. */
50 void time_start_timer(struct time_info
*ti
);
52 /* Set correct time information before making a move, and
53 * always make it time per move for the engine. */
54 void time_prepare_move(struct time_info
*ti
, struct board
*board
);
56 /* Returns the current time. */
57 double time_now(void);
59 /* Sleep for a given interval (in seconds). Return immediately if interval < 0. */
60 void time_sleep(double interval
);