Hash based prunning

Discussion of chess software programming and technical issues.

Moderator: Ras

Jose Carlos
Posts: 153
Joined: Wed Mar 08, 2006 10:09 pm
Location: Murcia (Spain)
Full name: José C. Martínez Galán

Hash based prunning

Post by Jose Carlos »

Hi. It's been quite many years since I last put my fingers on chess code. Recently, I found (by chance) the source code of Anubis, a chess program I never released because I considered it a piece of shit :)
I was curious, read the code and got hung again in CC world.
I've tried to fix obvious bugs and modernize the code, now that there's a lot of open source programs one can take ideas from, and quite some IAs that help understanding them.
I've uploaded the result here: https://github.com/Lacovipo/Anubis-chess-engine
BTW, I had a hard time understanding how the hell does github work :) I'm too old for this business.
I wanted to share an idea I haven't seen implemented in other engines. Probably it's not new at all, but I had not heard about it, so who knows.
The idea is to consider hash evaluated nodes as a kind of "leaf nodes" that you can do futility pruning against.
I'll try to explain myself through the code in Anubis:

Code: Select all

	if (pNodoHash != NULL)
	{
		jugHash = pNodoHash->jug;
		s32EvalHash = EvalFromTT(pNodoHash->jug.s32Val, s32Ply);
		s32ProfHash = pNodoHash->u8Prof;
		iBoundHash = Hash_GetBound(pNodoHash);

		//
		// Podas basadas en hash
		//
		#define PODA_HASH_PROF_DIF 1			// Máxima diferencia permitida de profundidad entre acutal y hash

		#define PODA_HASH_BETA_BASE 100			// Diferencia base contra beta
		#define PODA_HASH_BETA_MULT_DIF 100		// Multiplicador por cada diferencia de profundidad adicional en beta
		#define PODA_HASH_BETA_MULT_PROF 9		// Multiplicador por cada profundidad adicional en beta

		#define PODA_HASH_ALFA_BASE 250			// Diferencia base contra alfa
		#define PODA_HASH_ALFA_MULT_DIF 100		// Multiplicador por cada diferencia de profundidad adicional en alfa
		#define PODA_HASH_ALFA_MULT_PROF 10		// Multiplicador por cada profundidad adicional en alfa

		//
		// Poda hash beta
		//
		if (s32ProfHash >= s32Prof - PODA_HASH_PROF_DIF
			&& (iBoundHash == BOUND_LOWER || iBoundHash == BOUND_EXACTO)
			&& abs(s32Beta) < VICTORIA
			&& abs(s32EvalHash) < VICTORIA
			&& s32EvalHash > s32Beta + PODA_HASH_BETA_BASE + PODA_HASH_BETA_MULT_DIF * max(s32Prof - s32ProfHash, 1) + PODA_HASH_BETA_MULT_PROF * s32Prof)
		{
			return(s32Beta);
		}

		//
		// Poda hash alfa
		//
		if (s32ProfHash >= s32Prof - PODA_HASH_PROF_DIF
			&& (iBoundHash == BOUND_EXACTO || iBoundHash == BOUND_UPPER)
			&& abs(s32Alfa) < VICTORIA
			&& abs(s32EvalHash) < VICTORIA
			&& s32EvalHash < s32Alfa - PODA_HASH_ALFA_BASE - PODA_HASH_ALFA_MULT_DIF * max(s32Prof - s32ProfHash, 1) - PODA_HASH_ALFA_MULT_PROF * s32Prof)
		{
			return(s32Alfa);soft
		}
	}
jug stands for jugada (move)
prof stands for profundidad (depth)
PODA is prunning
And I think, the code is understandable for an english speaker.

The defines are starting values I'm testing. I need to modernize my testing framework, BTW, because it's realy obsolete...
I have hash information, but for less than current depth. So I imagine that is a leaf node and I do futility against it. But it's not a real leaf node, and I need different parameters. Right now I'm testing with diff == 1 (PODA_HASH_PROF_DIF) which means I test only of hashdepth == current depth - 1. But the idea is to extend that to 3 or 4 plies, using the other parameters I have defined.

As I said, I recently had the idea and I'm starting to test, but I'd like to know if this idea was already known and what do you think about it.
__________________________
José Carlos Martínez Galán
(Averno & Anubis)
User avatar
chrjly2
Posts: 14
Joined: Sat Aug 31, 2024 7:15 pm
Full name: Christophe Jolly

Re: Hash based prunning

Post by chrjly2 »

Futility child pruning and Razoring do the same, except that the evaluation value comes from the eval function or the hash table.