Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niklasf/magics
Finding magic factors for bitboard based move generation
https://github.com/niklasf/magics
bitboard chess hashtable
Last synced: 2 months ago
JSON representation
Finding magic factors for bitboard based move generation
- Host: GitHub
- URL: https://github.com/niklasf/magics
- Owner: niklasf
- License: gpl-3.0
- Created: 2018-04-08T12:49:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T05:21:00.000Z (about 2 years ago)
- Last Synced: 2024-05-01T18:57:56.841Z (8 months ago)
- Topics: bitboard, chess, hashtable
- Language: C
- Size: 2.02 MB
- Stars: 12
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
Finding magic factors for bitboard based move generation
========================================================Tool to find factors for [Magic bitboards](https://www.chessprogramming.org/Magic_Bitboards).
Exhaustive search
-----------------When looking for magic factors `m` with shift `w` it is sufficient to look
in the range `2^{64 - w - lsb(r_max)} <= m < 2^{64 - lsb(r_max)}` where
`r_max` is the maximum relevant occupancy for the square [1].Tricks for fast testing
-----------------------1. Avoid zero filling table (like Stockfish).
2. Dynamically reorder relevant occupancies to fail earlier on average.![Performance comparison](/fig-benchmark-rf8.png)
*Performance based on search of improved rook magics for f8.*
Tools
-----### `verify.py `
Verifies a magic candidate.
### `v1/magics `
Select `BISHOP` or `ROOK`, `SQUARE` and `EASY_SHIFT` in `v1/Makefile`,
`make` and run `./magics `. Tests all candidates in the specified range.### `v2/daq`
Select `BISHOP` or `ROOK`, `SQUARE` and `SHIFT` in `v2/Makefile`,
`make` and run `./daq`. Counts all magics with the specified settings.### `cuda/test`
Select square, piece type and shift in `generate.py`.
`make` and run `./test` to find magic factors with the specified
shift or disprove their existence. Works best for bishop squares (with small
shifts and small table sizes).References
----------1. [Disproving the existence of some magics](http://www.talkchess.com/forum/viewtopic.php?t=65187). 2017.
2. [No bishop magics with fixed shift 8](http://www.talkchess.com/forum/viewtopic.php?t=67051). 2018.