NNUE scoring (egbb lib)

Discussion of chess software programming and technical issues.

Moderator: Ras

tmokonen
Posts: 1362
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: NNUE scoring (egbb lib)

Post by tmokonen »

It looks like Daniel has deleted the file from his GitHub account. I have re-uploaded the latest version that I have. I hope Daniel doesn't mind. Sorry about using a file sharing service, my regular web hosting is not letting me log in today for some reason.

https://workupload.com/file/9WQ6GP9NSz8
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: NNUE scoring (egbb lib)

Post by Desperado »

tmokonen wrote: Tue May 25, 2021 2:09 am It looks like Daniel has deleted the file from his GitHub account. I have re-uploaded the latest version that I have. I hope Daniel doesn't mind. Sorry about using a file sharing service, my regular web hosting is not letting me log in today for some reason.

https://workupload.com/file/9WQ6GP9NSz8
Wow, it is a 14 MB file, can that be ? My own compile including EGBB and NNUE support is 74 KB.

Anyway, thanks for your support.
tmokonen
Posts: 1362
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: NNUE scoring (egbb lib)

Post by tmokonen »

Desperado wrote: Tue May 25, 2021 5:17 pm
tmokonen wrote: Tue May 25, 2021 2:09 am It looks like Daniel has deleted the file from his GitHub account. I have re-uploaded the latest version that I have. I hope Daniel doesn't mind. Sorry about using a file sharing service, my regular web hosting is not letting me log in today for some reason.

https://workupload.com/file/9WQ6GP9NSz8
Wow, it is a 14 MB file, can that be ? My own compile including EGBB and NNUE support is 74 KB.

Anyway, thanks for your support.
It's a 14MB zip containing one file - a 54MB dll! I am not sure why it is so huge. Perhaps an embedded net?
tmokonen
Posts: 1362
Joined: Sun Mar 12, 2006 6:46 pm
Location: Kelowna
Full name: Tony Mokonen

Re: NNUE scoring (egbb lib)

Post by tmokonen »

Actually, that file would not have NNUE support, as it predates NNUE. It only has support for the lc0 style nets. I am sorry to have wasted your time with that.

https://github.com/dshawul/Scorpio/rele ... ws-cpu.zip would contain the latest probing dlls. It contains four dll files:

egbbdll64.dll
nncpuprobe.dll
nnprobe.dll
nnueprobe.dll
User avatar
Desperado
Posts: 879
Joined: Mon Dec 15, 2008 11:45 am

Re: NNUE scoring (egbb lib)

Post by Desperado »

tmokonen wrote: Tue May 25, 2021 11:41 pm Actually, that file would not have NNUE support, as it predates NNUE. It only has support for the lc0 style nets. I am sorry to have wasted your time with that.

https://github.com/dshawul/Scorpio/rele ... ws-cpu.zip would contain the latest probing dlls. It contains four dll files:

egbbdll64.dll
nncpuprobe.dll
nnprobe.dll
nnueprobe.dll
Thank you again. I already downloaded that zip file but it did not help me (it did not work for me at that point).
Currently i am happy with my own compiled version.

I wonder if bitbase users use the various individual dll files or where they got a working dll.
I think most programmers build their own dll but then they need to release it too somewhere.

Unfortunately if nobody uses bitbases (anymore) for some reason it wouldn't be the best choice to go with it.
However, it's so easy to implement with little code and doesn't just provide the endgame databases but also nnue functionality for example.

My complete interface code looks like that. (2 functions,80 lines of code)

Code: Select all

HMODULE Egbb::hmod;
PLOAD_EGBB Egbb::load_egbb;
PPROBE_EGBB Egbb::probe_egbb;
PNNUE_INIT Egbb::nnue_init;
PNNUE_EVALUATE Egbb::nnue_evaluate;
BOOL Egbb::option_nnue = FALSE;
BOOL Egbb::option_egbb = FALSE;
char Egbb::dll_path[ID256] = "";
char Egbb::egbb_path[ID256] = "";
char Egbb::nnue_path[ID256] = "";

void Egbb::load()
{
    char path[ID256];

    strcpy_s(path, dll_path);
    strcat_s(path, 256, "\\egbbdll64.dll");

    // library available
    if(hmod = LoadLibraryA(path))
    {
        // connect interface functions
        load_egbb = (PLOAD_EGBB)GetProcAddress(hmod, "load_egbb_xmen");
        probe_egbb = (PPROBE_EGBB)GetProcAddress(hmod, "probe_egbb_xmen");
        nnue_init = (PNNUE_INIT)GetProcAddress(hmod, "nnue_init");
        nnue_evaluate = (PNNUE_EVALUATE)GetProcAddress(hmod, "nnue_evaluate");

        // option nnue available
        if(strcmp(nnue_path, ""))
        {
            option_nnue = TRUE; // TODO handle failure
            nnue_init(nnue_path);
        }
        else option_nnue = FALSE;

        // option egbb available
        if(strcmp(egbb_path, ""))
        {
            option_egbb = TRUE; // TODO handle failure
            char str[256];
            strcpy_s(str, egbb_path);
            strcat_s(str, 256, "/");
            load_egbb(str, MB1 * 256, 1); // TODO cache as option
        }
        else option_egbb = FALSE;
    }
    else option_nnue = option_egbb = FALSE;
}

int Egbb::probe(pos_t *pos)
{
    // scorpio bitbase enumeration
    enum {
        blank, wking, wqueen, wrook, wbishop, wknight, wpawn,
        bking, bqueen, brook, bbishop, bknight, bpawn
    };

    // internal piece ids
    int map[PID] ={
        0,0,wpawn,bpawn,wknight,bknight,wbishop,bbishop,wrook,brook,
        wqueen,bqueen,wking,bking
    };

    int piece[9], square[9], id = 2;

    piece[0] = wking; square[0] = Bit::lsb_id(pos->bb[WK]);
    piece[1] = bking; square[1] = Bit::lsb_id(pos->bb[BK]);

    uint64_t tmpsrc = Pos::occupied(pos) ^ (pos->bb[WK] | pos->bb[BK]);
    while(tmpsrc)
    {
        square[id] = Bit::pop_lsb(&tmpsrc);
        piece[id] = map[pos->sq[square[id]]];
        id++;
    }

    // Todo handle ep square and castle rights
    piece[id] = 0; square[id] = 0;

    return  probe_egbb(pos->stm, piece, square);
}