Continuation history implementation

Discussion of chess software programming and technical issues.

Moderators: hgm, chrisw, Rebel

jackk03
Posts: 18
Joined: Wed Jul 12, 2023 1:38 pm
Full name: Giacomo Porpiglia

Continuation history implementation

Post by jackk03 »

Hello everyone. I've been trying to implement continuation history into my engine for quite some time now, but have always failed in achieving a consistent elo gain. I guess I still don't have a clear idea on how does it work.
In particular, I'm going with this type of implementation:

static inline void updateContinuationHistories(MOVE move, int16_t bonus, SearchStack* ss) {

if((ss - 1)->move) {
int16_t& cont_history_1 = (ss - 1)->cont_history[board.colorToMove][pieceFrom(move)][getSquareTo(move)];
cont_history_1 += bonus - (cont_history_1 * std::abs(bonus) / MAX_HISTORY);
}
if((ss - 2)->move) {
int16_t& cont_history_2 = (ss - 2)->cont_history[board.colorToMove][pieceFrom(move)][getSquareTo(move)];
cont_history_2 += bonus - (cont_history_2 * std::abs(bonus) / MAX_HISTORY);
}
}


and then retrieve the continuation history score like this:

int getContHistoryScore(MOVE move, int* cm_hist, int* fm_hist, SearchStack* ss) {
int score = 0;

if((ss - 1)->move) {
if(cm_hist != NULL) {
*cm_hist = (int) (ss - 1)->cont_history[board.colorToMove][board.allPieces[getSquareFrom(move)]][getSquareTo(move)];

score += *cm_hist;
}
}

if((ss - 2)->move) {
if(fm_hist != NULL) {
*fm_hist = (int) (ss - 1)->cont_history[board.colorToMove][board.allPieces[getSquareFrom(move)]][getSquareTo(move)];

score += *fm_hist;
}
}
return score;
}


But what i don't understand is: what sense does it have to update the ch at ss-1, since the next time I'll be able to index its ch with a piece of the same color will be when I am at ss+2, and I'll therefore access ss+1 and ss as cm_hist and fm_hist?
Probably this doesn't make sense, but I'd be glad if someone helps me in understanding this!
Thanks
op12no2
Posts: 525
Joined: Tue Feb 04, 2014 12:25 pm
Location: Gower, Wales
Full name: Colin Jenkins

Re: Continuation history implementation

Post by op12no2 »

It seems like none of us are able to help you and it's been over three weeks, so have a go at asking in the Engine Programming Discord - specifically the Chess channel; my guess is that you'll get some help within minutes.

https://discord.gg/gNgPRym4

You've probably seen this, but just in case:-

https://www.chessprogramming.org/Histor ... on_History