fork(4) download
  1. #include <iostream>
  2. #include <stdint.h>
  3.  
  4. int main() {
  5. const auto n_hashbits = 5;
  6. auto magic = (1ull << 50) + (2ull << 39) + (3ull << 30) + (5ull << 21);
  7. std::cout << "Magic: " << std::hex << magic << std::dec << "\n";
  8.  
  9. for (auto square : {9, 11, 20, 29, 38}) {
  10. uint64_t bitboard = 1ull << square;
  11. uint64_t index = magic * bitboard;
  12. index >>= (64 - n_hashbits);
  13. std::cout << square << " => " << index << "\n";
  14. }
  15. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Magic: 40100c0a00000
9 => 1
11 => 4
20 => 2
29 => 3
38 => 5