Exemple #1
0
int SEARCHER::probe_bitbases(int* score,bool both) {
	
	register PLIST current;
	int piece[MAX_PIECES],square[MAX_PIECES],count = 0;

#define ADD_PIECE(list,type) {					\
	   current = list;							\
	   while(current) {							\
	      piece[count] = type;					\
		  square[count] = SQ8864(current->sq);	\
		  current = current->next;				\
		  count++;								\
	   }										\
	};
	ADD_PIECE(plist[wking],_WKING);
	ADD_PIECE(plist[bking],_BKING);
	ADD_PIECE(plist[wqueen],_WQUEEN);
	ADD_PIECE(plist[bqueen],_BQUEEN);
	ADD_PIECE(plist[wrook],_WROOK);
	ADD_PIECE(plist[brook],_BROOK);
	ADD_PIECE(plist[wbishop],_WBISHOP);
	ADD_PIECE(plist[bbishop],_BBISHOP);
	ADD_PIECE(plist[wknight],_WKNIGHT);
	ADD_PIECE(plist[bknight],_BKNIGHT);
	ADD_PIECE(plist[wpawn],_WPAWN);
	ADD_PIECE(plist[bpawn],_BPAWN);
	piece[count] = _EMPTY;
	square[count] = 0;

	score[0] = probe_egbb(player,piece,square);
	if(both)
		score[1] = probe_egbb(opponent,piece,square);
	
    return (score[0] != _NOTFOUND);
}
Exemple #2
0
//Probe EGBBs:
//Change interanal Stockfish board representaion to 
//EGBB board representation and then probe
Value EGBB::probe(const Position& pos, int ply, int depth, int fifty) {
	int npieces = pos.count<ALL_PIECES>(WHITE) + pos.count<ALL_PIECES>(BLACK);
	int dlimit = depth_limit * ONE_PLY;
	int plimit = (npieces < MAX_PIECES) ? ply_limit : ply_limit / 2;                   
	if(is_loaded && (ply > 1)                //must be loaded
		&& npieces <= MAX_PIECES             //maximum 6 pieces
		&& (depth >= dlimit || npieces <= 4) //hard depth limit
		&& (ply >= plimit || fifty == 0)     //ply above threshold or capt/pawn move
		); 
	else
		return VALUE_NONE;

	//Loop over pieces and fill up piece and square arrays
	Square s;
	int piece[8],square[8],count = 0;

#define ADD_PIECE(Piece,Col,PieceS) {			\
	const Square* pl = pos.list<Piece>(Col);	\
	while ((s = *pl++) != SQ_NONE) {			\
		piece[count] = PieceS;					\
		square[count] = s;						\
		count++;								\
	}											\
};

	ADD_PIECE(KING,   WHITE, _WKING);
	ADD_PIECE(KING,   BLACK, _BKING);
	ADD_PIECE(QUEEN,  WHITE, _WQUEEN);
	ADD_PIECE(QUEEN,  BLACK, _BQUEEN);
	ADD_PIECE(ROOK,   WHITE, _WROOK);
	ADD_PIECE(ROOK,   BLACK, _BROOK);
	ADD_PIECE(BISHOP, WHITE, _WBISHOP);
	ADD_PIECE(BISHOP, BLACK, _BBISHOP);
	ADD_PIECE(KNIGHT, WHITE, _WKNIGHT);
	ADD_PIECE(KNIGHT, BLACK, _BKNIGHT);
	ADD_PIECE(PAWN,   WHITE, _WPAWN);
	ADD_PIECE(PAWN,   BLACK, _BPAWN);
	piece[count] = _EMPTY;
	square[count] = pos.ep_square();

	//probe and return adjusted value
	int score = probe_egbb(
		(pos.side_to_move() == WHITE) ? _WHITE : _BLACK,
		piece,square);

	if(score == _NOTFOUND)
		return VALUE_NONE;
	else {
		tb_hits++;
		if(score > 0)
			return  VALUE_EGBB_WIN - VALUE_EGBB_PLY * ply + (score - 5000);
		else if(score < 0)
			return -VALUE_EGBB_WIN + VALUE_EGBB_PLY * ply + (score + 5000);
		else
			return VALUE_DRAW;
	}
}