Scid  4.6.5
stored.h
Go to the documentation of this file.
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 const uint STORED_LINES = 255;
24 
25 class StoredLine {
26 public:
27  StoredLine(const pieceT* board, colorT toMove);
28  //Result:
29  //-2 : the game cannot reach the searched position
30  //-1 : the game can reach the searched position
31  //>=0: the game reach the searched position at the returned ply
32  int match(uint code) {
33  if ((code > 0) && (code < STORED_LINES)) return matches_[code];
34  return -1;
35  }
36 
37  static uint count () { return STORED_LINES; }
38  static FullMove getMove (uint code, uint ply = 0) {
39  if ((code < STORED_LINES) && (Moves_[code] + ply) < Moves_[code +1]) {
40  return Moves_[code][ply];
41  }
42  return FullMove();
43  }
44 
45 private:
46  int matches_ [STORED_LINES];
47  static const FullMove* Moves_ [STORED_LINES +1];
48 };
49 
50 #endif // #ifndef SCID_STORED_H
51 
52 //////////////////////////////////////////////////////////////////////
53 // EOF: stored.h
54 //////////////////////////////////////////////////////////////////////
StoredLine(const pieceT *board, colorT toMove)
Definition: stored.cpp:634
static FullMove getMove(uint code, uint ply=0)
Definition: stored.h:38
const uint STORED_LINES
Definition: stored.h:23
static uint count()
Definition: stored.h:37
uint32_t uint
Definition: common.h:99
Definition: board.tcl:276
byte colorT
Definition: common.h:112
int match(uint code)
Definition: stored.h:32
byte pieceT
Definition: common.h:111