My first engine Tunguska is playing at 2100 ELO I believe, but before releasing it here, I want to try PVS + aspiration (and some tweaks to the eval, which is very simple by now).
To do this, I'm looking at the CPW code at https://github.com/nescitus/cpw-engine/ ... search.cpp.
Since I don't fully understand some details, I got confused at the hash probing code.
Here's my current code:
Code: Select all
//calling the hashprobe
int score = -INFINITE;
int pvMove = Move::NO_MOVE;
if( HashTable::probeHashEntry(board, &pvMove, &score, alpha, beta, depth)){
	board.hashTable->cut++;
	return score;
}Code: Select all
//Hash probe implementation
bool HashTable::probeHashEntry(Board& board, int *move, int *score, int alpha, int beta, int depth) {
	int index = (int)(board.zKey & board.hashTable->numEntries_1);
	if(board.hashTable->table[index].zKey == board.zKey) {
		*move = board.hashTable->table[index].move;
		if(board.hashTable->table[index].depth >= depth){
			board.hashTable->hit++;
			*score = board.hashTable->table[index].score;
			if(*score > ISMATE) 
				*score -= board.ply;
            else if(*score < -ISMATE) 
            	*score += board.ply;
            switch(board.hashTable->table[index].flags) {
                assert(*score >= -Search::INFINITE && *score <= Search::INFINITE);
                case HFALPHA: 
	            	if(*score <= alpha) {
	                	*score = alpha;
	                	return true;
	                }
	                break;
                case HFBETA: 
                	if(*score >= beta) {
                    	*score = beta;
                    	return true;
                    }
                    break;
                case HFEXACT:
                    return true;
                    break;
                default: assert(false); 
                break;
            }
		}
	}
	return false;
}Code: Select all
// in pv nodes we return only in case of an exact hash hit
if ((val = tt_probe(depth, alpha, beta, &tt_move_index)) != INVALID) {
	if (!is_pv || (val > alpha && val < beta)) {
		//mate val correction ommited
		return val;
	}
}Note: my search and hashtable code are taken fron the 'Vice' engine. I'm still absorving how all this works!
Thank you!
