{"id":17084422,"url":"https://github.com/niklasf/magics","last_synced_at":"2026-07-10T21:04:20.543Z","repository":{"id":50156436,"uuid":"128640672","full_name":"niklasf/magics","owner":"niklasf","description":"Finding magic factors for bitboard based move generation","archived":false,"fork":false,"pushed_at":"2026-05-06T19:51:42.000Z","size":2165,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-05-06T21:39:56.963Z","etag":null,"topics":["bitboard","chess","hashtable"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/niklasf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"niklasf"}},"created_at":"2018-04-08T12:49:38.000Z","updated_at":"2026-05-06T19:51:46.000Z","dependencies_parsed_at":"2023-01-25T11:00:54.010Z","dependency_job_id":null,"html_url":"https://github.com/niklasf/magics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/niklasf/magics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklasf%2Fmagics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklasf%2Fmagics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklasf%2Fmagics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklasf%2Fmagics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/niklasf","download_url":"https://codeload.github.com/niklasf/magics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/niklasf%2Fmagics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35343136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-10T02:00:06.465Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bitboard","chess","hashtable"],"created_at":"2024-10-14T13:07:06.208Z","updated_at":"2026-07-10T21:04:20.531Z","avatar_url":"https://github.com/niklasf.png","language":"C","funding_links":["https://github.com/sponsors/niklasf"],"categories":[],"sub_categories":[],"readme":"Finding magic factors for bitboard based move generation\n========================================================\n\nTool to find factors for [Magic bitboards](https://www.chessprogramming.org/Magic_Bitboards).\n\nResults\n-------\n\nAll magics for a given square are equivalent to a magic in the range\n`[0, period]` [1].\n\n`c` is the occupancy of the attack mask for the given square (the \"easy\" shift).\n\nTables contain magics for fixed shift and shift `c` with proven minimal\ntable size (attacks mapped to indexes from in `[0, range]`), as well as magics\nwith reduced shift `c - 1`.\n\nThe latter include [results from](https://www.chessprogramming.org/Best_Magics_so_far)\nGrant Osborne, Peter Österlund, Volker Annuss, Gerd Isenberg, and Richard Pijl.\nNew results in **bold**.\n\n### Rooks\n\n| | s | period | c | magic 12 | range 12 | magic c | range c | magic c - 1 |\n| --- | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: |\n| a1 | 0 | 2^63 | 12 | | | | | |\n| b1 | 1 | 2^62 | 11 | | | | | |\n| c1 | 2 | 2^63 | 11 | | | | | |\n| d1 | 3 | 2^63 | 11 | | | | | |\n| e1 | 4 | 2^63 | 11 | | | | | |\n| f1 | 5 | 2^63 | 11 | | | | | |\n| g1 | 6 | 2^63 | 11 | | | | | |\n| h1 | 7 | 2^63 | 12 | | | | | |\n| a2 | 8 | 2^55 | 11 | | | | | |\n| b2 | 9 | 2^54 | 10 | | | | | |\n| c2 | 10 | 2^55 | 10 | | | | | |\n| d2 | 11 | 2^55 | 10 | | | | | |\n| e2 | 12 | 2^55 | 10 | | | | | |\n| f2 | 13 | 2^55 | 10 | | | | | |\n| g2 | 14 | 2^55 | 10 | | | | | |\n| h2 | 15 | 2^55 | 11 | | | | | |\n| a3 | 16 | 2^56 | 11 | | | | | **disproved** |\n| b3 | 17 | 2^55 | 10 | | | | | **disproved** |\n| c3 | 18 | 2^54 | 10 | | | | | **disproved** |\n| d3 | 19 | 2^53 | 10 | | | | | **disproved** |\n| e3 | 20 | 2^52 | 10 | | | | | **disproved** |\n| f3 | 21 | 2^51 | 10 | | | | | **disproved** |\n| g3 | 22 | 2^50 | 10 | | | **0x2cd200990d0d1** | 1017 | **disproved** |\n| h3 | 23 | 2^49 | 11 | | | **0x1aad001575729** | 2038 | **disproved** |\n| a4 | 24 | 2^56 | 11 | | | | | **disproved** |\n| b4 | 25 | 2^55 | 10 | | | | | **disproved** |\n| c4 | 26 | 2^54 | 10 | | | | | **disproved** |\n| d4 | 27 | 2^53 | 10 | | | | | **disproved** |\n| e4 | 28 | 2^52 | 10 | | | | | **disproved** |\n| f4 | 29 | 2^51 | 10 | | | | | **disproved** |\n| g4 | 30 | 2^50 | 10 | | | **0x221100648734** | 1020 | **disproved** |\n| h4 | 31 | 2^49 | 11 | | | **0x137894006eced** | 2044 | **disproved** |\n| a5 | 32 | 2^56 | 11 | | | | | **disproved** |\n| b5 | 33 | 2^55 | 10 | | | | | **disproved** |\n| c5 | 34 | 2^54 | 10 | | | | | **disproved** |\n| d5 | 35 | 2^53 | 10 | | | | | **disproved** |\n| e5 | 36 | 2^52 | 10 | | | | | **disproved** |\n| f5 | 37 | 2^51 | 10 | | | | | **disproved** |\n| g5 | 38 | 2^50 | 10 | | | **0x605faf9fee00** | 1021 | **disproved** |\n| h5 | 39 | 2^49 | 11 | | | **0x4242136fff00** | 2045 | **disproved** |\n| a6 | 40 | 2^56 | 11 | | | | | **disproved** |\n| b6 | 41 | 2^55 | 10 | | | | | **disproved** |\n| c6 | 42 | 2^54 | 10 | | | | | **disproved** |\n| d6 | 43 | 2^53 | 10 | | | | | **disproved** |\n| e6 | 44 | 2^52 | 10 | | | | | **disproved** |\n| f6 | 45 | 2^51 | 10 | | | | | **disproved** |\n| g6 | 46 | 2^50 | 10 | | | **0x100f9483800a** | 1016 | **disproved** |\n| h6 | 47 | 2^49 | 11 | | | **0x6c6c92246ffe** | 2040 | **disproved** |\n| a7 | 48 | 2^56 | 11 | | | | | 0x48fffe99fecfaa00 |\n| b7 | 49 | 2^55 | 10 | | | | | 0x48fffe99fecfaa00 |\n| c7 | 50 | 2^54 | 10 | | | | | 0x497fffadff9c2e00 |\n| d7 | 51 | 2^53 | 10 | | | | | 0x613fffddffce9200 |\n| e7 | 52 | 2^52 | 10 | | | | | 0xffffffe9ffe7ce00 |\n| f7 | 53 | 2^51 | 10 | | | | | 0xfffffff5fff3e600 |\n| g7 | 54 | 2^50 | 10 | | | **0x20a09f80801e0** | 998 | **0x3ff95e5e6a4c0** |\n| h7 | 55 | 2^49 | 11 | | | | | 0x510ffff5f63c96a0 |\n| a8 | 56 | 2^56 | 12 | | | | | 0xebffffb9ff9fc526 |\n| b8 | 57 | 2^55 | 11 | | | | | 0x61fffeddfeedaeae |\n| c8 | 58 | 2^54 | 11 | | | | | 0x53bfffedffdeb1a2 |\n| d8 | 59 | 2^53 | 11 | | | | | 0x127fffb9ffdfb5f6 |\n| e8 | 60 | 2^52 | 11 | | | | | 0x411fffddffdbf4d6 |\n| f8 | 61 | 2^51 | 11 | | | | | **disproved** |\n| g8 | 62 | 2^50 | 10 | | | | | 0x3ffef27eebe74 |\n| h8 | 63 | 2^49 | 12 | | | | | 0x7645fffecbfea79e |\n\n### Bishops\n\n| | s | period | c | magic 9 | range 9 | magic c | range c | magic c - 1 |\n| --- | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: |\n| a1 | 0 | 2^55 | 6 | | | | | 0xffedf9fd7cfcffff |\n| b1 | 1 | 2^54 | 5 | | | | | 0xfc0962854a77f576 |\n| c1 | 2 | 2^55 | 5 | | | | | |\n| d1 | 3 | 2^54 | 5 | | | | | |\n| e1 | 4 | 2^53 | 5 | | | | | **disproved** |\n| f1 | 5 | 2^52 | 5 | | | | | **disproved** |\n| g1 | 6 | 2^51 | 5 | | | | | 0xfc0a66c64a7ef576 |\n| h1 | 7 | 2^50 | 6 | | | | | 0x7ffdfdfcbd79ffff |\n| a2 | 8 | 2^47 | 5 | | | | | 0xfc0846a64a34fff6 |\n| b2 | 9 | 2^46 | 5 | | | | | 0xfc087a874a3cf7f6 |\n| c2 | 10 | 2^47 | 5 | | | | | **disproved** |\n| d2 | 11 | 2^46 | 5 | | | | | **disproved** |\n| e2 | 12 | 2^45 | 5 | **0x4402000000** | 62 | **0x8f24760b248** | 30 | **disproved** |\n| f2 | 13 | 2^44 | 5 | **0x21c1007bff** | 59 | **0xa21427af62** | 28 | **disproved** |\n| g2 | 14 | 2^43 | 5 | **0x1041040040** | 61 | **0x52e9060be9** | 22 | 0x820a13ffe0 |\n| h2 | 15 | 2^42 | 5 | **0x820820020** | 61 | **0x29748305f5** | 22 | **0x410509fff0** |\n| a3 | 16 | 2^55 | 5 | | | | | 0x73c01af56cf4cffb |\n| b3 | 17 | 2^54 | 5 | | | | | 0x41a01cfad64aaffc |\n| c3 | 18 | 2^55 | 7 | | | | | **disproved** |\n| d3 | 19 | 2^54 | 7 | | | | | **disproved** |\n| e3 | 20 | 2^53 | 7 | | | | | **disproved** |\n| f3 | 21 | 2^52 | 7 | | | | | **disproved** |\n| g3 | 22 | 2^51 | 5 | | | | | 0x7c0c028f5b34ff76 |\n| h3 | 23 | 2^50 | 5 | | | | | 0xfc0a028e5ab4df76 |\n| a4 | 24 | 2^54 | 5 | | | | | **disproved** |\n| b4 | 25 | 2^53 | 5 | | | | | **disproved** |\n| c4 | 26 | 2^52 | 7 | | | | | **disproved** |\n| d4 | 27 | 2^55 | 9 | | | | | **disproved** |\n| e4 | 28 | 2^54 | 9 | | | | | **disproved** |\n| f4 | 29 | 2^53 | 7 | | | | | **disproved** |\n| g4 | 30 | 2^52 | 5 | | | | | **disproved** |\n| h4 | 31 | 2^51 | 5 | | | | | **disproved** |\n| a5 | 32 | 2^53 | 5 | | | | | **disproved** |\n| b5 | 33 | 2^52 | 5 | | | | | **disproved** |\n| c5 | 34 | 2^51 | 7 | | | | | **disproved** |\n| d5 | 35 | 2^50 | 9 | **0x20080080080** | 511 | **0x20080080080** | 511 | **disproved** |\n| e5 | 36 | 2^55 | 9 | | | | | **disproved** |\n| f5 | 37 | 2^54 | 7 | | | | | **disproved** |\n| g5 | 38 | 2^53 | 5 | | | | | **disproved** |\n| h5 | 39 | 2^52 | 5 | | | | | **disproved** |\n| a6 | 40 | 2^52 | 5 | | | | | 0xdcefd9b54bfcc09f |\n| b6 | 41 | 2^51 | 5 | | | | | 0xf95ffa765afd602b |\n| c6 | 42 | 2^50 | 7 | | | | | **disproved** |\n| d6 | 43 | 2^42 | 7 | **0x8840200040** | 132 | **0xa44000800** | 127 | **disproved** |\n| e6 | 44 | 2^47 | 7 | | | | | **disproved** |\n| f6 | 45 | 2^55 | 7 | | | | | **disproved** |\n| g6 | 46 | 2^54 | 5 | | | | | 0x43ff9a5cf4ca0c01 |\n| h6 | 47 | 2^53 | 5 | | | | | 0x4bffcd8e7c587601 |\n| a7 | 48 | 2^51 | 5 | | | | | 0xfc0ff2865334f576 |\n| b7 | 49 | 2^50 | 5 | | | | | 0xfc0bf6ce5924f576 |\n| c7 | 50 | 2^42 | 5 | **0x820806000** | 35 | **0x50c34179e6** | 29 | **disproved** |\n| d7 | 51 | 2^34 | 5 | **0x8403000** | 60 | **0x20880000** | 31 | **disproved** |\n| e7 | 52 | 2^39 | 5 | **0x100202000** | 31 | **0x4f68bcb86d** | 29 | **disproved** |\n| f7 | 53 | 2^47 | 5 | | | | | **disproved** |\n| g7 | 54 | 2^55 | 5 | | | | | 0xc3ffb7dc36ca8c89 |\n| h7 | 55 | 2^54 | 5 | | | | | 0xc3ff8a54f4ca2c89 |\n| a8 | 56 | 2^50 | 6 | | | | | 0xfffffcfcfd79edff |\n| b8 | 57 | 2^42 | 5 | **0x820820020** | 61 | **0x58c328c2ee** | 22 | 0x1ec04eae595 |\n| c8 | 58 | 2^34 | 5 | **0x8208060** | 35 | **0x50c3417a** | 29 | **disproved** |\n| d8 | 59 | 2^26 | 5 | **0x84030** | 60 | **0x208800** | 31 | **disproved** |\n| e8 | 60 | 2^31 | 5 | **0x1002020** | 31 | **0x4f68bcb9** | 29 | **disproved** |\n| f8 | 61 | 2^39 | 5 | **0x40408020** | 31 | **0x74486419f** | 26 | **disproved** |\n| g8 | 62 | 2^47 | 5 | | | | | 0xfc087e8e4bb2f736 |\n| h8 | 63 | 2^55 | 6 | | | | | 0x43ff9e4ef4ca2c89 |\n\nTools\n-----\n\n### `verify.py \u003cCANDIDATE\u003e`\n\nVerifies a magic candidate.\n\n### `v2/daq`\n\nSelect `BISHOP` or `ROOK`, `SQUARE` and `SHIFT` in `v2/Makefile`,\n`make` and run `./daq`. Counts all magics with the specified settings.\n\n### `gpu/test`\n\nSelect square, piece type and shift in `generate.py`.\n`make` and run `./test` to find magic factors with the specified\nshift or disprove their existence. Works best for bishop squares (with small\nshifts and small table sizes).\n\nReferences\n----------\n\n1. [Disproving the existence of some magics](http://www.talkchess.com/forum/viewtopic.php?t=65187). 2017.\n2. [No bishop magics with fixed shift 8](http://www.talkchess.com/forum/viewtopic.php?t=67051). 2018.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklasf%2Fmagics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fniklasf%2Fmagics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fniklasf%2Fmagics/lists"}