Scid  4.7.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 (const 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)
 
std::pair< uint16_t, uint16_t > hpSig_make (const pieceT *board)
 Creates a 16-bits bitmap of the missing pawns in the home ranks. More...
 
bool hpSig_match (int hpSig, int nMoved, const byte *changeList)
 

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

◆ MASK_BB

#define MASK_BB   0x000000C0

Definition at line 56 of file matsig.h.

◆ MASK_BN

#define MASK_BN   0x00000030

Definition at line 55 of file matsig.h.

◆ MASK_BP

#define MASK_BP   0x0000000F

Definition at line 54 of file matsig.h.

◆ MASK_BQ

#define MASK_BQ   0x00000C00

Definition at line 58 of file matsig.h.

◆ MASK_BR

#define MASK_BR   0x00000300

Definition at line 57 of file matsig.h.

◆ MASK_WB

#define MASK_WB   0x000C0000

Definition at line 61 of file matsig.h.

◆ MASK_WN

#define MASK_WN   0x00030000

Definition at line 60 of file matsig.h.

◆ MASK_WP

#define MASK_WP   0x0000F000

Definition at line 59 of file matsig.h.

◆ MASK_WQ

#define MASK_WQ   0x00C00000

Definition at line 63 of file matsig.h.

◆ MASK_WR

#define MASK_WR   0x00300000

Definition at line 62 of file matsig.h.

◆ MATSIG_Count_BB

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

Definition at line 138 of file matsig.h.

◆ MATSIG_Count_BN

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

Definition at line 140 of file matsig.h.

◆ MATSIG_Count_BP

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

Definition at line 142 of file matsig.h.

◆ MATSIG_Count_BQ

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

Definition at line 134 of file matsig.h.

◆ MATSIG_Count_BR

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

Definition at line 136 of file matsig.h.

◆ MATSIG_Count_WB

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

Definition at line 137 of file matsig.h.

◆ MATSIG_Count_WN

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

Definition at line 139 of file matsig.h.

◆ MATSIG_Count_WP

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

Definition at line 141 of file matsig.h.

◆ MATSIG_Count_WQ

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

Definition at line 133 of file matsig.h.

◆ MATSIG_Count_WR

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

Definition at line 135 of file matsig.h.

◆ MATSIG_FlipColor

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

Definition at line 108 of file matsig.h.

◆ MATSIG_Has_BB

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

Definition at line 118 of file matsig.h.

◆ MATSIG_Has_BN

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

Definition at line 120 of file matsig.h.

◆ MATSIG_Has_BP

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

Definition at line 122 of file matsig.h.

◆ MATSIG_Has_BQ

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

Definition at line 114 of file matsig.h.

◆ MATSIG_Has_BR

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

Definition at line 116 of file matsig.h.

◆ MATSIG_Has_WB

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

Definition at line 117 of file matsig.h.

◆ MATSIG_Has_WN

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

Definition at line 119 of file matsig.h.

◆ MATSIG_Has_WP

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

Definition at line 121 of file matsig.h.

◆ MATSIG_Has_WQ

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

Definition at line 113 of file matsig.h.

◆ MATSIG_Has_WR

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

Definition at line 115 of file matsig.h.

◆ MATSIG_HasBishops

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

Definition at line 126 of file matsig.h.

◆ MATSIG_HasKnights

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

Definition at line 127 of file matsig.h.

◆ MATSIG_HasPawns

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

Definition at line 128 of file matsig.h.

◆ MATSIG_HasQueens

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

Definition at line 124 of file matsig.h.

◆ MATSIG_HasRooks

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

Definition at line 125 of file matsig.h.

◆ SHIFT_BB

#define SHIFT_BB   6

Definition at line 42 of file matsig.h.

◆ SHIFT_BN

#define SHIFT_BN   4

Definition at line 41 of file matsig.h.

◆ SHIFT_BP

#define SHIFT_BP   0

Definition at line 40 of file matsig.h.

◆ SHIFT_BQ

#define SHIFT_BQ   10

Definition at line 44 of file matsig.h.

◆ SHIFT_BR

#define SHIFT_BR   8

Definition at line 43 of file matsig.h.

◆ SHIFT_WB

#define SHIFT_WB   18

Definition at line 47 of file matsig.h.

◆ SHIFT_WN

#define SHIFT_WN   16

Definition at line 46 of file matsig.h.

◆ SHIFT_WP

#define SHIFT_WP   12

Definition at line 45 of file matsig.h.

◆ SHIFT_WQ

#define SHIFT_WQ   22

Definition at line 49 of file matsig.h.

◆ SHIFT_WR

#define SHIFT_WR   20

Definition at line 48 of file matsig.h.

Typedef Documentation

◆ matSigT

typedef uint32_t matSigT

Definition at line 25 of file matsig.h.

Function Documentation

◆ hpSig_AddPawn()

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

Definition at line 271 of file matsig.h.

◆ hpSig_ClearPawn()

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

Definition at line 282 of file matsig.h.

◆ hpSig_Final()

uint hpSig_Final ( const byte changeList)

Definition at line 177 of file matsig.cpp.

◆ hpSig_make()

std::pair<uint16_t, uint16_t> hpSig_make ( const pieceT board)
inline

Creates a 16-bits bitmap of the missing pawns in the home ranks.

Used to speed up the searches of positions with the same pawn structure.

Returns
a std::pair containing the bitmap and the number of moved pawns.

Definition at line 298 of file matsig.h.

◆ hpSig_match()

bool hpSig_match ( int  hpSig,
int  nMoved,
const byte changeList 
)
inline

Definition at line 325 of file matsig.h.

◆ hpSig_PossibleMatch()

bool hpSig_PossibleMatch ( uint  hpSig,
const byte changeList 
)

Definition at line 97 of file matsig.cpp.

◆ hpSig_Prefix()

bool hpSig_Prefix ( const byte changeListA,
const byte changeListB 
)

Definition at line 140 of file matsig.cpp.

◆ matsig_getCount()

uint matsig_getCount ( matSigT  m,
pieceT  p 
)
inline

Definition at line 149 of file matsig.h.

◆ matsig_isReachable()

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

Definition at line 56 of file matsig.cpp.

◆ matsig_isReachablePawns()

bool matsig_isReachablePawns ( matSigT  mStart,
matSigT  mTarget 
)
inline

Definition at line 213 of file matsig.h.

◆ matsig_Make()

matSigT matsig_Make ( const byte materialCounts)
inline

Definition at line 225 of file matsig.h.

◆ matsig_makeString()

std::string matsig_makeString ( matSigT  matsig)

Definition at line 27 of file matsig.cpp.

◆ matsig_setCount()

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

Definition at line 159 of file matsig.h.

Variable Documentation

◆ HPSIG_Empty

const uint HPSIG_Empty = 0x0

Definition at line 246 of file matsig.h.

◆ HPSIG_StdStart

const uint HPSIG_StdStart = 0xFFFF

Definition at line 249 of file matsig.h.

◆ MASK_BY_PIECE

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.

◆ MATSIG_Empty

const matSigT MATSIG_Empty = 0

Definition at line 176 of file matsig.h.

◆ MATSIG_StdStart

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.

◆ SHIFT_BY_PIECE

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.