1 /* Copyright (C) 2007-2011 Vincent Ollivier
3 * Purple Haze is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
8 * Purple Haze is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 // Set the time to play the game
27 unsigned int allowed_moves
;
28 unsigned int allowed_time
; // In centi-seconds
30 // Set the time to play a move
31 clock_t starting_time
;
32 unsigned long long int allocated_time
; // Calculated
33 unsigned int remaining_time
; // Given by protocols like Xboard
36 unsigned int polling_interval
;
37 unsigned int last_poll_nodes_count
;
42 allowed_moves(40), allowed_time(24000),
43 allocated_time(allowed_time
/ allowed_moves
),
44 remaining_time(allowed_time
/ allowed_moves
),
45 polling_interval(500000), last_poll_nodes_count(0),
49 Time(unsigned int moves
, unsigned int time
) :
50 allowed_moves(moves
), allowed_time(time
),
51 allocated_time(allowed_time
/ allowed_moves
),
52 remaining_time(allowed_time
/ allowed_moves
),
53 polling_interval(500000), last_poll_nodes_count(0),
57 void set_polling_interval(unsigned int nodes
) {
58 polling_interval
= nodes
;
60 void set_remaining_time(unsigned int time
) {
61 remaining_time
= time
;
63 unsigned long long int get_allocated_time() const {
64 return allocated_time
;
66 unsigned long long int get_elapsed_time() {
67 unsigned long long int elapsed
= clock() - starting_time
;
68 return 100 * elapsed
/ CLOCKS_PER_SEC
;
70 void start_thinking(unsigned int ply
);
71 bool is_out_of_time();
72 bool poll(unsigned int nodes_count
);