Zobrist free

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Zobrist free

Post by Henk »

I went back to my old bitboard key. Disadvantage is that it's slower and also costs more memory.

Code: Select all

   public Key(IChessBoardBits board)
        {
            rep = new ulong[SIZE];
            rep[0] = board.Pawns;
            rep[1] = board.Kings;
            rep[2] = board.Knights;
            rep[3] = board.Bishops;
            rep[4] = board.Rooks;
            rep[5] = board.Queens;
            rep[6] = board.WhitePieces;
            rep[7] = board.Other;
        }
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Zobrist free

Post by Ras »

Henk wrote:I went back to my old bitboard key. Disadvantage is that it's slower and also costs more memory.
On the upside, this means that the NSA has more problems hacking the key.
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Zobrist free

Post by Henk »

Yes I used the last position of the last game I played at 31-12-2016 to generate my password for my account.

By the way I only had to fix a few hundred compile errors and a bad run time error to change it back. Talking about maintainable software.
Ras
Posts: 2488
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Zobrist free

Post by Ras »

Henk wrote:Talking about maintainable software.
Uhm.. version control / backup? Even just saving the whole folder into a ZIP archive named by date may work.
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Zobrist free

Post by stegemma »

Really? Why?
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Zobrist free

Post by Henk »

I wanted to eliminate the risk of a hash collision. So if there is a bug or a bad move being played I can be sure it's not because of that. May be 8 x 64 bits is a bit too expensive.
User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Zobrist free

Post by stegemma »

For this I add the FEN string to the TT entries when I want to test for collisions; that make easier to debug (it slows down the program more than your solution, of course).

Another way could be to just add an extra hash value of the whole 8x64 bits, maybe with sum/rotations, so to have a single extra 64 bit key.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
Henk
Posts: 7220
Joined: Mon May 27, 2013 10:31 am

Re: Zobrist free

Post by Henk »

I also did not like the code I created for Zobrist key. With bit boards key you don't have to update the key for that has already been done.

Don't know what is the minimal size for a complete key. Probably about 4 x 64 bits I guess.
AlvaroBegue
Posts: 931
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: Zobrist free

Post by AlvaroBegue »

Henk wrote:I also did not like the code I created for Zobrist key. With bit boards key you don't have to update the key for that has already been done.

Don't know what is the minimal size for a complete key. Probably about 4 x 64 bits I guess.
4 x 64 bits is 256 bits. John Tromp has a proof that the number of chess diagrams is at most 2^155. So you can do better than 256 bits, even after you take castling rights and en-passant state into account.
Pio
Posts: 334
Joined: Sat Feb 25, 2012 10:42 pm
Location: Stockholm

Re: Zobrist free

Post by Pio »

Hi Henk!

I save my board in 3*64 = 192 bits but you can do it more efficiently. See my post http://www.talkchess.com/forum/viewtopi ... 93&t=49575

You can also see the quad board representation on the superb chess programming wiki if you want a compact and fast representation.

/Pio