Vasik,
Can you show some unimportant code of rybka .
Can you show some unimportant code of rybka .
Sorry - it's on another machine, I'd have to go fetch it.
Vas
Vas
It would be interesting to see your coding style. I write C in a pure Kernighan and Ritchie manner, and others' preferences are fun to look at.
All right, fine - here's white knight captures :):
for (bb_t knights = Board.pieces [WN]; knights; knights &= knights-1)
{
int knight_sq = bit_scan (knights);
for (bb_t captures = knight_moves [knight_sq] & opponent_pieces; captures; captures &= captures - 1)
{
int capture_sq = bit_scan (captures);
*moves ++ = move (knight_sq, capture_sq);
*values ++ = Board.sq [capture_sq] * 256 + 192;
}
}
Vas
for (bb_t knights = Board.pieces [WN]; knights; knights &= knights-1)
{
int knight_sq = bit_scan (knights);
for (bb_t captures = knight_moves [knight_sq] & opponent_pieces; captures; captures &= captures - 1)
{
int capture_sq = bit_scan (captures);
*moves ++ = move (knight_sq, capture_sq);
*values ++ = Board.sq [capture_sq] * 256 + 192;
}
}
Vas
How about piece (knight,queen,king,bishop,pawn,rook) attacks? Is the smp code sacred too? If not, can you make it public?
It's all sacred :)
Vas
Vas
Funny nick BTW :)
Vas
Vas
Not funny if it gets nicked though! :)
Hmm, I wish I hadn't seen this. It's hard to respect someone that doesn't use the One True Brace Style :-) Did you start out in Pascal or Algol?
Yes, Pascal. For some reason, I like some space in my code. I also almost never comment anything, only very brief 'section headings'.
Vas
Vas
The author of glaurung chess thinks that if the program is open source then it would be impossible to clone because clones can be detected very quickly because of similarities.
I think you are using bitboards .
Cool. Thanks.
Hah, I was right in an earlier post -- bitmap representation indeed. :-)
/* Steinar */
/* Steinar */
Ah, +192! That's the secret! How stupid of me! Now it all makes sense!
:-)
:-)
How could a knight be anything other than 192? :)
Vas
Vas
Is it pure C? or does it include inline assembly?
Any MMX, SSE optimizations?
Don't worry Vas, i'm not asking for a sample code :)
Any MMX, SSE optimizations?
Don't worry Vas, i'm not asking for a sample code :)
Here is the reversed Rybka source which corresponds to Vasik's code fragment:
eax = M0076d068;
ecx = M0076d06c;
V14 = eax;
V18 = ecx;
if(!(eax = V14 | ecx)) { // this is the outer 'for' loop
do {
eax = V14;
if(eax == 0) {
asm("bsf ecx,[esp+0x28]");
V4 = ecx;
V4 = V4 + 0x20;
} else {
asm("bsf eax,eax");
V4 = eax;
}
ecx = V4; // this is the bit_scan() functon
eax = M0076d088;
edx = M0076d08c;
esi = ecx;
ecx = *(ecx * 4 + 0x53cd90);
esi = esi << 6;
V10 = esi;
edx = M0076d084;
ecx = *(V4 * 4 + 0x53cc90);
eax = M0076d080;
edi = (L005376E0() & 0x3f) + esi;
edx = M0076d094;
ecx = *(V4 * 4 + 0x53ca90);
eax = (L005376E0() & 0x3f) + esi;
esi = *(edi * 8 + 0x554e90);
edi = *(edi * 8 + 0x554e94);
esi = esi | *(eax * 8 + 0x54ce90);
edi = edi | *(eax * 8 + 0x54ce94);
eax = M0076d090;
edx = M0076d09c;
ecx = *(V4 * 4 + 0x53cb90);
eax = (L005376E0() & 0x3f) + V10;
esi = esi | *(eax * 8 + 0x53ce90);
edi = edi | *(eax * 8 + 0x53ce94);
eax = M0076d098;
eax = (L005376E0() & 0x3f) + V10;
esi = esi | *(eax * 8 + 0x544e90);
edi = edi | *(eax * 8 + 0x544e94);
esi = esi & A24;
edi = edi & A28;
if(!(edx = esi | edi)) { // this is the inner 'for' loop
ecx = V4 << 6;
do {
if(esi == 0) {
asm("bsf eax,edi");
V10 = eax;
eax = eax + 0x20;
} else {
asm("bsf eax,esi");
}
edx = eax;
eax = *(eax * 4 + 7786256);
*ebx = edx | ecx;
edx = eax - 2 & 8;
*ebp = edx + (eax << 8) + 0xc0; // * 256 + 192
edx = esi;
ebx = ebx + 4; // moves ++
ebp = ebp + 4; // values ++
edx = edx - 1;
eax = edi; // check for inner loop termination
asm("adc eax,byte -0x1");
esi = esi & edx;
edi = edi & eax;
} while(edx = esi | edi);
}
eax = V14; // check for outer loop termination
ecx = V18;
edx = eax - 1;
esi = ecx;
asm("adc esi,byte -0x1");
eax = eax & edx;
ecx = ecx & esi;
V14 = eax;
V18 = ecx;
} while(eax = eax | ecx);
}
eax = M0076d068;
ecx = M0076d06c;
V14 = eax;
V18 = ecx;
if(!(eax = V14 | ecx)) { // this is the outer 'for' loop
do {
eax = V14;
if(eax == 0) {
asm("bsf ecx,[esp+0x28]");
V4 = ecx;
V4 = V4 + 0x20;
} else {
asm("bsf eax,eax");
V4 = eax;
}
ecx = V4; // this is the bit_scan() functon
eax = M0076d088;
edx = M0076d08c;
esi = ecx;
ecx = *(ecx * 4 + 0x53cd90);
esi = esi << 6;
V10 = esi;
edx = M0076d084;
ecx = *(V4 * 4 + 0x53cc90);
eax = M0076d080;
edi = (L005376E0() & 0x3f) + esi;
edx = M0076d094;
ecx = *(V4 * 4 + 0x53ca90);
eax = (L005376E0() & 0x3f) + esi;
esi = *(edi * 8 + 0x554e90);
edi = *(edi * 8 + 0x554e94);
esi = esi | *(eax * 8 + 0x54ce90);
edi = edi | *(eax * 8 + 0x54ce94);
eax = M0076d090;
edx = M0076d09c;
ecx = *(V4 * 4 + 0x53cb90);
eax = (L005376E0() & 0x3f) + V10;
esi = esi | *(eax * 8 + 0x53ce90);
edi = edi | *(eax * 8 + 0x53ce94);
eax = M0076d098;
eax = (L005376E0() & 0x3f) + V10;
esi = esi | *(eax * 8 + 0x544e90);
edi = edi | *(eax * 8 + 0x544e94);
esi = esi & A24;
edi = edi & A28;
if(!(edx = esi | edi)) { // this is the inner 'for' loop
ecx = V4 << 6;
do {
if(esi == 0) {
asm("bsf eax,edi");
V10 = eax;
eax = eax + 0x20;
} else {
asm("bsf eax,esi");
}
edx = eax;
eax = *(eax * 4 + 7786256);
*ebx = edx | ecx;
edx = eax - 2 & 8;
*ebp = edx + (eax << 8) + 0xc0; // * 256 + 192
edx = esi;
ebx = ebx + 4; // moves ++
ebp = ebp + 4; // values ++
edx = edx - 1;
eax = edi; // check for inner loop termination
asm("adc eax,byte -0x1");
esi = esi & edx;
edi = edi & eax;
} while(edx = esi | edi);
}
eax = V14; // check for outer loop termination
ecx = V18;
edx = eax - 1;
esi = ecx;
asm("adc esi,byte -0x1");
eax = eax & edx;
ecx = ecx & esi;
V14 = eax;
V18 = ecx;
} while(eax = eax | ecx);
}
Powered by mwForum 2.27.4 © 1999-2012 Markus Wichitill
