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/>.
27 unsigned int interval
;
28 unsigned int previous
;
29 Polling() : interval(50000), previous(0) {}
32 // Set the time to play the game
33 unsigned int level_moves
;
34 unsigned int level_time
; // In centi-seconds
36 // Set the time to play a move
38 unsigned long long int time_per_move
; // Calculated
39 unsigned int remaining
; // Given by protocols like Xboard
45 Time(unsigned int moves
= 40, unsigned int time
= 24000) :
46 level_moves(moves
), level_time(time
),
47 time_per_move(level_time
/ level_moves
),
48 remaining(time_per_move
),
52 void set_polling_interval(const unsigned int nodes
) {
53 polling
.interval
= nodes
;
55 void set_remaining(const unsigned int time
) {
58 unsigned long long int allocated() const {
61 unsigned long long int elapsed() const {
62 unsigned long long int clocks
= clock() - start
;
63 return 100 * clocks
/ CLOCKS_PER_SEC
;
65 void start_thinking(const unsigned int ply
);
66 bool is_out_of_time() const;
67 bool poll(const unsigned int node_count
);