Line data Source code
1 : /*
2 : * Copyright (C) 2014 Fulvio Benini
3 :
4 : * This file is part of Scid (Shane's Chess Information Database).
5 : *
6 : * Scid is free software: you can redistribute it and/or modify
7 : * it under the terms of the GNU General Public License as published by
8 : * the Free Software Foundation.
9 : *
10 : * Scid is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 : * GNU General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU General Public License
16 : * along with Scid. If not, see <http://www.gnu.org/licenses/>.
17 : */
18 :
19 : #ifndef SCID_STORED_H
20 : #define SCID_STORED_H
21 :
22 : #include "fullmove.h"
23 :
24 : class StoredLine {
25 : static const unsigned STORED_LINES = 255;
26 : static const FullMove* Moves_[STORED_LINES + 1];
27 :
28 : int8_t matches_[STORED_LINES + 1];
29 :
30 : public:
31 : StoredLine(const pieceT* board, colorT toMove);
32 :
33 : // Result:
34 : //-2 : the game cannot reach the searched position
35 : //-1 : the game can reach the searched position
36 : //>=0: the game reach the searched position at the returned ply
37 : int match(byte code) const { return matches_[code]; }
38 :
39 2298825 : static uint count () { return STORED_LINES; }
40 2425730 : static FullMove getMove (uint code, uint ply = 0) {
41 2425730 : if ((code < STORED_LINES) && (Moves_[code] + ply) < Moves_[code +1]) {
42 2418828 : return Moves_[code][ply];
43 : }
44 6902 : return FullMove();
45 : }
46 : };
47 :
48 : #endif // #ifndef SCID_STORED_H
49 :
50 : //////////////////////////////////////////////////////////////////////
51 : // EOF: stored.h
52 : //////////////////////////////////////////////////////////////////////
|