Scid  4.6.5
recog.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////
2 //
3 // FILE: recog.h
4 // Endgame knowledge recognition class
5 //
6 // Part of: Scid (Shane's Chess Information Database)
7 // Version: 3.4
8 //
9 // Notice: Copyright (c) 2002 Shane Hudson. All rights reserved.
10 //
11 // Author: Shane Hudson (sgh@users.sourceforge.net)
12 //
13 //////////////////////////////////////////////////////////////////////
14 
15 #include "engine.h"
16 #include "position.h"
17 
18 // The Recognizer class provides score bound information for chess
19 // endgames.
20 
21 // Only positions with a total of 6 or fewer pieces (including kings
22 // and pawns) are potentially recognizable.
23 static const uint MAX_RECOGNIZED_PIECES = 6;
24 
25 // Recognition value conversion: a recognition score contains a
26 // regular score shifted left 4 bits to make room for a score flag.
27 
28 inline int recogValue (scoreFlagT flag, int score) {
29  return ((score * 16) | flag);
30 }
31 inline int recogScore (int value) { return value / 16; }
32 inline scoreFlagT recogFlag (int value) { return value & 15; }
33 
35 {
36  private:
37  static int KPK (Position * pos);
38 
39  static int KBBK (Position * pos);
40  static int KBNK (Position * pos);
41  static int KBPK (Position * pos);
42 
43  static int KRKB (Position * pos);
44  static int KRKN (Position * pos);
45  static int KMKP (Position * pos);
46  static int KQKP (Position * pos);
47  static int KRKP (Position * pos);
48 
49  static int KRPKR (Position * pos);
50 
51  public:
52 #ifdef WINCE
53  void* operator new(size_t sz) {
54  void* m = my_Tcl_Alloc(sz);
55  return m;
56  }
57  void operator delete(void* m) {
58  my_Tcl_Free((char*)m);
59  }
60  void* operator new [] (size_t sz) {
61  void* m = my_Tcl_AttemptAlloc(sz);
62  return m;
63  }
64 
65  void operator delete [] (void* m) {
66  my_Tcl_Free((char*)m);
67  }
68 
69 #endif
70 
71  static uint MaxPieces (void) { return MAX_RECOGNIZED_PIECES; }
72  static int Recognize (Position * pos);
73 };
74 
75 //////////////////////////////////////////////////////////////////////
76 // EOF: recog.h
77 //////////////////////////////////////////////////////////////////////
static int Recognize(Position *pos)
Definition: recog.cpp:34
scoreFlagT recogFlag(int value)
Definition: recog.h:32
uint32_t uint
Definition: common.h:99
byte scoreFlagT
Definition: engine.h:49
static uint MaxPieces(void)
Definition: recog.h:71
int recogScore(int value)
Definition: recog.h:31
int recogValue(scoreFlagT flag, int score)
Definition: recog.h:28