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) {}
34 unsigned int time
; // Centiseconds
35 Clock(int m
, int t
) : moves(m
), time(t
) {}
42 bool is_out_of_time() const;
45 Time(const int moves
= 40, const int time
= 5 * 60 * 100) :
51 void set_polling_interval(const unsigned int nodes
) {
52 polling
.interval
= nodes
;
54 void set_remaining(const unsigned int time
) {
57 unsigned int allocated() const {
58 assert(level
.moves
>= clock
.moves
);
59 const unsigned int moves
= level
.moves
- clock
.moves
+ 1;
60 return clock
.time
/ moves
;
62 unsigned long long int elapsed() const {
63 const unsigned long long int clocks
= std::clock() - start
;
64 return 100 * clocks
/ CLOCKS_PER_SEC
;
69 void start_thinking(const unsigned int ply
);
70 bool poll(const unsigned int node_count
);