Uri Blass wrote:strelka has a big array Distance[64][64] to calculate distance between squares
I have the following definition in movei to calculate the same thing
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define FileDistance(a,b) abs(((a)&7) - ((b)&7))
#define RankDistance(a,b) abs(((a)>>3) - ((b)>>3))
#define Distance(a,b) Max(FileDistance(a,b),RankDistance(a,b))
I added this definition to strelka and found that Distance(i,j) in my code is always equal to Distance[i][j] in strelka for 0<=i,j<=63
My question is which code is better for speed.
Uri
Hi Uri,
I guess you need to run the program to see which version is faster. I too have such a distance array in my engine and what I noticed is that it seems to matter from where you access such an array.
While I had a tremendous speedup by using the distance array in my move generation when generating legal moves it didn't gave me a speedup when calling the array directly from the search when generating pseudo legal moves. It was not faster than calling attack() (to check if the move leads/leaves in check) after making every move.
So I guess you need to actually test to conclude which version is faster.
regards
Roman