First things first, I have read the chess programming wiki, and know roughly how a chess engine works.
I would like to ask you all what you think to my (IMO rubbish) idea.
It is basically a move ordering type search. It works by starting with a piece type (say, the king), and searches for d depth, using only that piece type (king) moves. If we get a beta cutoff, we open the window to +INFINITY and -INFINITY, and search again (Transposition Table may be useful for this bit); if this causes a cutoff, we return beta(fail-hard) or the value of the full window search. If we get a value that is alpha > value > beta, we give alpha and beta a window of, say, half a pawn;
The issue with this is that you have always got to be aware of the fact that there may not be any available moves. For this reason, in my pseudocode, I have added a parameter, which tells us if the search had any available moves. If we are in check, and king moves returns no moves, then we may well have a checkmate. If we are not in check, and all pieces give no moves, then it's stalemate.
I have nicknamed it the "commitee" move pruner, because of the way it consults all moves(-ish) before returning a score.
Code: Select all
int comSearch(int alpha, int beta, int depth, pvtype * BestMove) // I've included the latter parameter so that it is easy to get the PV
{
int val, moves;
pvtype pv;
val = KingSearch(alpha, beta, depth, &pv, &moves);
if (val > beta) {
alpha = +INFINITY;
beta = -INFINITY;
val = KingSearch(alpha, beta, depth, &pv); // research
if (val > beta)
return beta;
}
else if (val > alpha) {
alpha = val;
beta = val + 50;
BestMove = pv;
}
// continue for other piece types
if (moves = 0) {
if (AreWeInCheck())
return val_checkmate;
return val_contempt;
}
return alpha; // alpha should be the same as the best value;
}
Also, why do we have 8*8 bitboards with all the bit twiddling? Why don't we have 16*8 bitboards, with several properties of 0x88 (you could fit two bitboards there, one for, say, white bishops, and one for black bishops)?
A noob saying...
Matthew:out