Scid  4.6.5
Macros | Typedefs | Functions | Variables
matsig.h File Reference
#include "common.h"
#include <algorithm>
#include <string>
Include dependency graph for matsig.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SHIFT_BP   0
 
#define SHIFT_BN   4
 
#define SHIFT_BB   6
 
#define SHIFT_BR   8
 
#define SHIFT_BQ   10
 
#define SHIFT_WP   12
 
#define SHIFT_WN   16
 
#define SHIFT_WB   18
 
#define SHIFT_WR   20
 
#define SHIFT_WQ   22
 
#define MASK_BP   0x0000000F
 
#define MASK_BN   0x00000030
 
#define MASK_BB   0x000000C0
 
#define MASK_BR   0x00000300
 
#define MASK_BQ   0x00000C00
 
#define MASK_WP   0x0000F000
 
#define MASK_WN   0x00030000
 
#define MASK_WB   0x000C0000
 
#define MASK_WR   0x00300000
 
#define MASK_WQ   0x00C00000
 
#define MATSIG_FlipColor(x)   ((x) >> 12) | (((x) & 0x00000FFF) << 12)
 
#define MATSIG_Has_WQ(x)   ((x) & MASK_WQ)
 
#define MATSIG_Has_BQ(x)   ((x) & MASK_BQ)
 
#define MATSIG_Has_WR(x)   ((x) & MASK_WR)
 
#define MATSIG_Has_BR(x)   ((x) & MASK_BR)
 
#define MATSIG_Has_WB(x)   ((x) & MASK_WB)
 
#define MATSIG_Has_BB(x)   ((x) & MASK_BB)
 
#define MATSIG_Has_WN(x)   ((x) & MASK_WN)
 
#define MATSIG_Has_BN(x)   ((x) & MASK_BN)
 
#define MATSIG_Has_WP(x)   ((x) & MASK_WP)
 
#define MATSIG_Has_BP(x)   ((x) & MASK_BP)
 
#define MATSIG_HasQueens(x)   ((x) & (MASK_WQ | MASK_BQ))
 
#define MATSIG_HasRooks(x)   ((x) & (MASK_WR | MASK_BR))
 
#define MATSIG_HasBishops(x)   ((x) & (MASK_WB | MASK_BB))
 
#define MATSIG_HasKnights(x)   ((x) & (MASK_WN | MASK_BN))
 
#define MATSIG_HasPawns(x)   ((x) & (MASK_WP | MASK_BP))
 
#define MATSIG_Count_WQ(x)   (((x) & MASK_WQ) >> SHIFT_WQ)
 
#define MATSIG_Count_BQ(x)   (((x) & MASK_BQ) >> SHIFT_BQ)
 
#define MATSIG_Count_WR(x)   (((x) & MASK_WR) >> SHIFT_WR)
 
#define MATSIG_Count_BR(x)   (((x) & MASK_BR) >> SHIFT_BR)
 
#define MATSIG_Count_WB(x)   (((x) & MASK_WB) >> SHIFT_WB)
 
#define MATSIG_Count_BB(x)   (((x) & MASK_BB) >> SHIFT_BB)
 
#define MATSIG_Count_WN(x)   (((x) & MASK_WN) >> SHIFT_WN)
 
#define MATSIG_Count_BN(x)   (((x) & MASK_BN) >> SHIFT_BN)
 
#define MATSIG_Count_WP(x)   (((x) & MASK_WP) >> SHIFT_WP)
 
#define MATSIG_Count_BP(x)   (((x) & MASK_BP) >> SHIFT_BP)
 

Typedefs

typedef uint32_t matSigT
 

Functions

uint matsig_getCount (matSigT m, pieceT p)
 
matSigT matsig_setCount (matSigT m, pieceT p, uint count)
 
std::string matsig_makeString (matSigT matsig)
 
bool matsig_isReachable (matSigT mStart, matSigT mTarget, bool promos, bool upromo)
 
bool matsig_isReachablePawns (matSigT mStart, matSigT mTarget)
 
matSigT matsig_Make (byte *materialCounts)
 
bool hpSig_PossibleMatch (uint hpSig, const byte *changeList)
 
bool hpSig_Prefix (const byte *changeListA, const byte *changeListB)
 
uint hpSig_Final (const byte *changeList)
 
uint hpSig_AddPawn (uint hpSig, colorT color, fyleT fyle)
 
uint hpSig_ClearPawn (uint hpSig, colorT color, fyleT fyle)
 

Variables

const matSigT MASK_BY_PIECE [16]
 
const uint SHIFT_BY_PIECE [16]
 
const matSigT MATSIG_Empty = 0
 
const matSigT MATSIG_StdStart
 
const uint HPSIG_Empty = 0x0
 
const uint HPSIG_StdStart = 0xFFFF
 

Macro Definition Documentation

#define MASK_BB   0x000000C0

Definition at line 56 of file matsig.h.

#define MASK_BN   0x00000030

Definition at line 55 of file matsig.h.

#define MASK_BP   0x0000000F

Definition at line 54 of file matsig.h.

#define MASK_BQ   0x00000C00

Definition at line 58 of file matsig.h.

#define MASK_BR   0x00000300

Definition at line 57 of file matsig.h.

#define MASK_WB   0x000C0000

Definition at line 61 of file matsig.h.

#define MASK_WN   0x00030000

Definition at line 60 of file matsig.h.

#define MASK_WP   0x0000F000

Definition at line 59 of file matsig.h.

#define MASK_WQ   0x00C00000

Definition at line 63 of file matsig.h.

#define MASK_WR   0x00300000

Definition at line 62 of file matsig.h.

#define MATSIG_Count_BB (   x)    (((x) & MASK_BB) >> SHIFT_BB)

Definition at line 138 of file matsig.h.

#define MATSIG_Count_BN (   x)    (((x) & MASK_BN) >> SHIFT_BN)

Definition at line 140 of file matsig.h.

#define MATSIG_Count_BP (   x)    (((x) & MASK_BP) >> SHIFT_BP)

Definition at line 142 of file matsig.h.

#define MATSIG_Count_BQ (   x)    (((x) & MASK_BQ) >> SHIFT_BQ)

Definition at line 134 of file matsig.h.

#define MATSIG_Count_BR (   x)    (((x) & MASK_BR) >> SHIFT_BR)

Definition at line 136 of file matsig.h.

#define MATSIG_Count_WB (   x)    (((x) & MASK_WB) >> SHIFT_WB)

Definition at line 137 of file matsig.h.

#define MATSIG_Count_WN (   x)    (((x) & MASK_WN) >> SHIFT_WN)

Definition at line 139 of file matsig.h.

#define MATSIG_Count_WP (   x)    (((x) & MASK_WP) >> SHIFT_WP)

Definition at line 141 of file matsig.h.

#define MATSIG_Count_WQ (   x)    (((x) & MASK_WQ) >> SHIFT_WQ)

Definition at line 133 of file matsig.h.

#define MATSIG_Count_WR (   x)    (((x) & MASK_WR) >> SHIFT_WR)

Definition at line 135 of file matsig.h.

#define MATSIG_FlipColor (   x)    ((x) >> 12) | (((x) & 0x00000FFF) << 12)

Definition at line 108 of file matsig.h.

#define MATSIG_Has_BB (   x)    ((x) & MASK_BB)

Definition at line 118 of file matsig.h.

#define MATSIG_Has_BN (   x)    ((x) & MASK_BN)

Definition at line 120 of file matsig.h.

#define MATSIG_Has_BP (   x)    ((x) & MASK_BP)

Definition at line 122 of file matsig.h.

#define MATSIG_Has_BQ (   x)    ((x) & MASK_BQ)

Definition at line 114 of file matsig.h.

#define MATSIG_Has_BR (   x)    ((x) & MASK_BR)

Definition at line 116 of file matsig.h.

#define MATSIG_Has_WB (   x)    ((x) & MASK_WB)

Definition at line 117 of file matsig.h.

#define MATSIG_Has_WN (   x)    ((x) & MASK_WN)

Definition at line 119 of file matsig.h.

#define MATSIG_Has_WP (   x)    ((x) & MASK_WP)

Definition at line 121 of file matsig.h.

#define MATSIG_Has_WQ (   x)    ((x) & MASK_WQ)

Definition at line 113 of file matsig.h.

#define MATSIG_Has_WR (   x)    ((x) & MASK_WR)

Definition at line 115 of file matsig.h.

#define MATSIG_HasBishops (   x)    ((x) & (MASK_WB | MASK_BB))

Definition at line 126 of file matsig.h.

#define MATSIG_HasKnights (   x)    ((x) & (MASK_WN | MASK_BN))

Definition at line 127 of file matsig.h.

#define MATSIG_HasPawns (   x)    ((x) & (MASK_WP | MASK_BP))

Definition at line 128 of file matsig.h.

#define MATSIG_HasQueens (   x)    ((x) & (MASK_WQ | MASK_BQ))

Definition at line 124 of file matsig.h.

#define MATSIG_HasRooks (   x)    ((x) & (MASK_WR | MASK_BR))

Definition at line 125 of file matsig.h.

#define SHIFT_BB   6

Definition at line 42 of file matsig.h.

#define SHIFT_BN   4

Definition at line 41 of file matsig.h.

#define SHIFT_BP   0

Definition at line 40 of file matsig.h.

#define SHIFT_BQ   10

Definition at line 44 of file matsig.h.

#define SHIFT_BR   8

Definition at line 43 of file matsig.h.

#define SHIFT_WB   18

Definition at line 47 of file matsig.h.

#define SHIFT_WN   16

Definition at line 46 of file matsig.h.

#define SHIFT_WP   12

Definition at line 45 of file matsig.h.

#define SHIFT_WQ   22

Definition at line 49 of file matsig.h.

#define SHIFT_WR   20

Definition at line 48 of file matsig.h.

Typedef Documentation

typedef uint32_t matSigT

Definition at line 25 of file matsig.h.

Function Documentation

uint hpSig_AddPawn ( uint  hpSig,
colorT  color,
fyleT  fyle 
)
inline

Definition at line 273 of file matsig.h.

uint hpSig_ClearPawn ( uint  hpSig,
colorT  color,
fyleT  fyle 
)
inline

Definition at line 284 of file matsig.h.

uint hpSig_Final ( const byte changeList)

Definition at line 177 of file matsig.cpp.

bool hpSig_PossibleMatch ( uint  hpSig,
const byte changeList 
)

Definition at line 97 of file matsig.cpp.

bool hpSig_Prefix ( const byte changeListA,
const byte changeListB 
)

Definition at line 140 of file matsig.cpp.

uint matsig_getCount ( matSigT  m,
pieceT  p 
)
inline

Definition at line 149 of file matsig.h.

bool matsig_isReachable ( matSigT  mStart,
matSigT  mTarget,
bool  promos,
bool  upromo 
)

Definition at line 56 of file matsig.cpp.

bool matsig_isReachablePawns ( matSigT  mStart,
matSigT  mTarget 
)
inline

Definition at line 213 of file matsig.h.

matSigT matsig_Make ( byte materialCounts)
inline

Definition at line 226 of file matsig.h.

std::string matsig_makeString ( matSigT  matsig)

Definition at line 27 of file matsig.cpp.

matSigT matsig_setCount ( matSigT  m,
pieceT  p,
uint  count 
)
inline

Definition at line 159 of file matsig.h.

Variable Documentation

const uint HPSIG_Empty = 0x0

Definition at line 248 of file matsig.h.

const uint HPSIG_StdStart = 0xFFFF

Definition at line 251 of file matsig.h.

const matSigT MASK_BY_PIECE[16]
Initial value:
= {
0,
0,
0, 0,
0,
0
}
#define MASK_WQ
Definition: matsig.h:63
#define MASK_WR
Definition: matsig.h:62
#define MASK_BR
Definition: matsig.h:57
#define MASK_BQ
Definition: matsig.h:58
#define MASK_WB
Definition: matsig.h:61
#define MASK_WN
Definition: matsig.h:60
#define MASK_BN
Definition: matsig.h:55
#define MASK_WP
Definition: matsig.h:59
#define MASK_BP
Definition: matsig.h:54
#define MASK_BB
Definition: matsig.h:56

Definition at line 70 of file matsig.h.

const matSigT MATSIG_Empty = 0

Definition at line 176 of file matsig.h.

const matSigT MATSIG_StdStart
Initial value:
=
((1 << SHIFT_WQ) | (1 << SHIFT_BQ) | (2 << SHIFT_WR) | (2 << SHIFT_BR) |
(2 << SHIFT_WB) | (2 << SHIFT_BB) | (2 << SHIFT_WN) | (2 << SHIFT_BN) |
(8 << SHIFT_WP) | (8 << SHIFT_BP))
#define SHIFT_WR
Definition: matsig.h:48
#define SHIFT_BR
Definition: matsig.h:43
#define SHIFT_BP
Definition: matsig.h:40
#define SHIFT_WP
Definition: matsig.h:45
#define SHIFT_WN
Definition: matsig.h:46
#define SHIFT_BB
Definition: matsig.h:42
#define SHIFT_WQ
Definition: matsig.h:49
#define SHIFT_BQ
Definition: matsig.h:44
#define SHIFT_WB
Definition: matsig.h:47
#define SHIFT_BN
Definition: matsig.h:41

Definition at line 178 of file matsig.h.

const uint SHIFT_BY_PIECE[16]
Initial value:
= {
0, 0,
0, 0, 0,
0
}
#define SHIFT_WR
Definition: matsig.h:48
#define SHIFT_BR
Definition: matsig.h:43
#define SHIFT_BP
Definition: matsig.h:40
#define SHIFT_WP
Definition: matsig.h:45
#define SHIFT_WN
Definition: matsig.h:46
#define SHIFT_BB
Definition: matsig.h:42
#define SHIFT_WQ
Definition: matsig.h:49
#define SHIFT_BQ
Definition: matsig.h:44
#define SHIFT_WB
Definition: matsig.h:47
#define SHIFT_BN
Definition: matsig.h:41

Definition at line 89 of file matsig.h.