Not logged inRybka Chess Community Forum
Up Topic Rybka Support & Discussion / Rybka Discussion / rybka source code
- - By kaustubh (**) [in] Date 2007-07-12 13:49
Vasik,
          Can you show some unimportant code of rybka .
Parent - - By Vasik Rajlich (Silver) [hu] Date 2007-07-14 06:16
Sorry - it's on another machine, I'd have to go fetch it.

Vas
Parent - - By herakleitos (***) Date 2007-07-22 15:16
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.
Parent - - By Vasik Rajlich (Silver) [hu] Date 2007-07-24 06:31
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
Parent - - By V.Deferens [hu] Date 2007-07-24 06:54
How about piece (knight,queen,king,bishop,pawn,rook) attacks? Is the smp code sacred too? If not, can you make it public?
Parent - - By Vasik Rajlich (Silver) [hu] Date 2007-07-24 07:42
It's all sacred :)

Vas
Parent - - By Vasik Rajlich (Silver) [hu] Date 2007-07-24 07:42
Funny nick BTW :)

Vas
Parent - By Graham Banks (*****) [nz] Date 2007-07-25 21:53
Not funny if it gets nicked though!   :)
Parent - - By Banned for Life (Gold) Date 2007-07-24 09:01
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?
Parent - By Vasik Rajlich (Silver) [hu] Date 2007-07-26 08:40
Yes, Pascal. For some reason, I like some space in my code. I also almost never comment anything, only very brief 'section headings'.

Vas
Parent - By kaustubh (**) [in] Date 2007-07-24 11:40
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.
Parent - By kaustubh (**) [in] Date 2007-07-24 11:47
I think you are using bitboards .
Parent - By herakleitos (***) Date 2007-07-24 13:20
Cool. Thanks.
Parent - By Sesse (****) [no] Date 2007-07-24 18:52
Hah, I was right in an earlier post -- bitmap representation indeed. :-)

/* Steinar */
Parent - - By mjlef (***) [cz] Date 2007-07-25 11:10
Ah, +192!  That's the secret! How stupid of me!  Now it all makes sense!

:-)
Parent - By Vasik Rajlich (Silver) [hu] Date 2007-07-26 08:41
How could a knight be anything other than 192? :)

Vas
Parent - - By JhorAVi (***) [ph] Date 2007-07-22 23:35
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 :)
Parent - By RVisitor (*) [us] Date 2007-07-26 07:19
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);
    }
Up Topic Rybka Support & Discussion / Rybka Discussion / rybka source code

Powered by mwForum 2.27.4 © 1999-2012 Markus Wichitill