Hey what's up guys, Code Monkey King's here.
I've never been implementing Zobrist hashing before.
A couple of days ago I've successfully(hopefully) embedded it into my chess engine (covered on YT like many of you know).
So obviously I've covered Zobrist hashing along with other engine development topics in the series as well.
Now assuming the style I'm using (which is hated by many for it's dumbness which I consider to be a benefit)
these tutorials (3 videos) might be considered as STAND ALONE Zobrist hashing tutorials that beginners
can make use of regardless of the entire engine.
So here are the links with a quick descriptions:
https://www.youtube.com/watch?v=W7dah-d ... s&index=67
defining and initializing random keys to hash position key, based on PRMG I made before for generating magic numbers for magic bitboards.
so it creates SAME hash keys regardless of environment
https://www.youtube.com/watch?v=sV2C7hx ... s&index=68
generating of a "almost" unique position identifier aka hash key from scratch
so it can be later used for indexing of transposition table and detecting 3 fold repetitions
And finally the most intriguing part - INCREMENTAL UPDATES of hash keys within a make move function.
Obviously this part is implementation dependent but the debugging scheme I use here is very clear and straightforward.
Also I want to give a credit to Pedro Castro who has kindly explained to me how this debugging is done:
http://talkchess.com/forum3/viewtopic.php?f=7&t=75126
Hope this would be useful to someone.
Zobrist hashing tutorials on YouTube
Moderators: hgm, Rebel, chrisw
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Zobrist hashing tutorials on YouTube
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 385
- Joined: Sat Feb 04, 2017 11:57 pm
- Location: USA
Re: Zobrist hashing tutorials on YouTube
I use the Polyglot random numbers for my Zobrist hashing for the following reasons:
1. they already exist, why reinvent the wheel.
2. the position hash will always match what the polyglot books require for lookup, so there isn't any further regeneration of another hash needed to probe the book.
3. it saves memory space.
4. it provides a way to validate the hash algorithm. make moves from the starting position and then probe the book. if you get the correct hit, you know both the hashing and probing are working.
here is the link to Harm's write up...
http://hgm.nubati.net/book_format.html
I created a C++ class to wrap everything into a nice tidy package.
1. they already exist, why reinvent the wheel.
2. the position hash will always match what the polyglot books require for lookup, so there isn't any further regeneration of another hash needed to probe the book.
3. it saves memory space.
4. it provides a way to validate the hash algorithm. make moves from the starting position and then probe the book. if you get the correct hit, you know both the hashing and probing are working.
here is the link to Harm's write up...
http://hgm.nubati.net/book_format.html
I created a C++ class to wrap everything into a nice tidy package.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: Zobrist hashing tutorials on YouTube
MOBMAT wrote: ↑Sat Sep 19, 2020 3:50 pm I use the Polyglot random numbers for my Zobrist hashing for the following reasons:
1. they already exist, why reinvent the wheel.
2. the position hash will always match what the polyglot books require for lookup, so there isn't any further regeneration of another hash needed to probe the book.
3. it saves memory space.
4. it provides a way to validate the hash algorithm. make moves from the starting position and then probe the book. if you get the correct hit, you know both the hashing and probing are working.
here is the link to Harm's write up...
http://hgm.nubati.net/book_format.html
I created a C++ class to wrap everything into a nice tidy package.
Cool. Didn't know about that, thanks.1. they already exist, why reinvent the wheel.
C++ is rocket science for me...I created a C++ class to wrap everything into a nice tidy package.
I'm forced to use OOP in my freelance jobs, so at least in chess programming I can go for good old plain functional C
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
-
- Posts: 385
- Joined: Sat Feb 04, 2017 11:57 pm
- Location: USA
Re: Zobrist hashing tutorials on YouTube
I code in what I call C+. No, not C or C++, but C+.maksimKorzh wrote: ↑Mon Sep 21, 2020 2:01 amMOBMAT wrote: ↑Sat Sep 19, 2020 3:50 pm I use the Polyglot random numbers for my Zobrist hashing for the following reasons:
1. they already exist, why reinvent the wheel.
2. the position hash will always match what the polyglot books require for lookup, so there isn't any further regeneration of another hash needed to probe the book.
3. it saves memory space.
4. it provides a way to validate the hash algorithm. make moves from the starting position and then probe the book. if you get the correct hit, you know both the hashing and probing are working.
here is the link to Harm's write up...
http://hgm.nubati.net/book_format.html
I created a C++ class to wrap everything into a nice tidy package.Cool. Didn't know about that, thanks.1. they already exist, why reinvent the wheel.
C++ is rocket science for me...I created a C++ class to wrap everything into a nice tidy package.
I'm forced to use OOP in my freelance jobs, so at least in chess programming I can go for good old plain functional C
That refers to using features of both languages, mostly being what C developers really wanted in a OO language, such as classes. The language should be used to support the requirements, not the other way around. I recall once a conversation with a colleague who used the following example. If you are writing code to send rockets into space, you aren't going to chose a language that at any time, can arbitrarily decide when it is going to do memory garbage collection. But don't get me started... LOL
Knowing C makes it easy to understand what C++ is doing. If you learn C++ first, a lot of the underlying processes are glossed over. I like to know what my code is doing.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
-
- Posts: 771
- Joined: Sat Sep 08, 2018 5:37 pm
- Location: Ukraine
- Full name: Maksim Korzh
Re: Zobrist hashing tutorials on YouTube
MOBMAT wrote: ↑Mon Sep 21, 2020 3:26 pmThanks for clarificationmaksimKorzh wrote: ↑Mon Sep 21, 2020 2:01 amMOBMAT wrote: ↑Sat Sep 19, 2020 3:50 pm I use the Polyglot random numbers for my Zobrist hashing for the following reasons:
1. they already exist, why reinvent the wheel.
2. the position hash will always match what the polyglot books require for lookup, so there isn't any further regeneration of another hash needed to probe the book.
3. it saves memory space.
4. it provides a way to validate the hash algorithm. make moves from the starting position and then probe the book. if you get the correct hit, you know both the hashing and probing are working.
here is the link to Harm's write up...
http://hgm.nubati.net/book_format.html
I created a C++ class to wrap everything into a nice tidy package.Cool. Didn't know about that, thanks.1. they already exist, why reinvent the wheel.
C++ is rocket science for me...I created a C++ class to wrap everything into a nice tidy package.
I'm forced to use OOP in my freelance jobs, so at least in chess programming I can go for good old plain functional C
I code in what I call C+. No, not C or C++, but C+.
That refers to using features of both languages, mostly being what C developers really wanted in a OO language, such as classes. The language should be used to support the requirements, not the other way around. I recall once a conversation with a colleague who used the following example. If you are writing code to send rockets into space, you aren't going to chose a language that at any time, can arbitrarily decide when it is going to do memory garbage collection. But don't get me started... LOL
Knowing C makes it easy to understand what C++ is doing. If you learn C++ first, a lot of the underlying processes are glossed over. I like to know what my code is doing.
Didactic chess engines:
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ
https://www.chessprogramming.org/Maksim_Korzh
Chess programming YouTube channel:
https://www.youtube.com/channel/UCB9-pr ... KKqDgXhsMQ