Moderator: Andres Valverde
I can't remember which squares failed but I shall take another look. If you use a constant to re-locate the bits you will probably have to use a different constant for each square and you may not need to AND it with its compliment as the occupancy has already been masked.
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
##############
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
j
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
m
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
n
##############
aijnbcdekfghpm
10000
10000a000bcde0fgh000
10000a000bcde0fgh0000i0000000
10000a000bcde0fgh0000i0000000j0000000k0000000m000
0000000000000001000000000000000000010000000010000000000000010000
0000 0000 0000 0001 0000 0000 0000 0000 0001 0000 0000 1000 0000 0000 0001 0000
0x0001000010080010 magic
0000a000bcde0fgh0000i0000000j0000000k0000000m0000000n0000000p000
j m n
0000000000000000000000111111100000000000001110000000100000000000
0000 0000 0000 0000 0000 0011 1111 1000 0000 0000 0011 1000 0000 1000 0000 0000
000003f800380800
hello world
***Failed***
magic for 0 is 0000000000000000
***Failed***
magic for 1 is 0000000000000000
magic for 2 is 0100020C08102001
magic for 3 is 0100008208100401
magic for 4 is 0100004820860405
magic for 5 is 0100004820860405
magic for 6 is 0300090000804022
magic for 7 is 0100028010200C41
***Failed***
magic for 8 is 0000000000000000
***Failed***
magic for 9 is 0000000000000000
***Failed***
magic for 10 is 0000000000000000
***Failed***
magic for 11 is 0000000000000000
***Failed***
magic for 12 is 0000000000000000
***Failed***
magic for 13 is 0000000000000000
***Failed***
magic for 14 is 0000000000000000
***Failed***
magic for 15 is 0000000000000000
***Failed***
magic for 16 is 0000000000000000
***Failed***
magic for 17 is 0000000000000000
***Failed***
magic for 18 is 0000000000000000
***Failed***
magic for 19 is 0000000000000000
***Failed***
magic for 20 is 0000000000000000
***Failed***
magic for 21 is 0000000000000000
***Failed***
magic for 22 is 0000000000000000
***Failed***
magic for 23 is 0000000000000000
***Failed***
magic for 24 is 0000000000000000
***Failed***
magic for 25 is 0000000000000000
***Failed***
magic for 26 is 0000000000000000
***Failed***
magic for 27 is 0000000000000000
***Failed***
magic for 28 is 0000000000000000
***Failed***
magic for 29 is 0000000000000000
***Failed***
magic for 30 is 0000000000000000
***Failed***
magic for 31 is 0000000000000000
***Failed***
magic for 32 is 0000000000000000
***Failed***
magic for 33 is 0000000000000000
***Failed***
magic for 34 is 0000000000000000
***Failed***
magic for 35 is 0000000000000000
magic for 36 is 3200010402001008
magic for 37 is 0100040003001082
***Failed***
magic for 38 is 0000000000000000
***Failed***
magic for 39 is 0000000000000000
***Failed***
magic for 40 is 0000000000000000
***Failed***
magic for 41 is 0000000000000000
***Failed***
magic for 42 is 0000000000000000
***Failed***
magic for 43 is 0000000000000000
***Failed***
magic for 44 is 0000000000000000
***Failed***
magic for 45 is 0000000000000000
***Failed***
magic for 46 is 0000000000000000
***Failed***
magic for 47 is 0000000000000000
***Failed***
magic for 48 is 0000000000000000
***Failed***
magic for 49 is 0000000000000000
***Failed***
magic for 50 is 0000000000000000
***Failed***
magic for 51 is 0000000000000000
***Failed***
magic for 52 is 0000000000000000
***Failed***
magic for 53 is 0000000000000000
***Failed***
magic for 54 is 0000000000000000
***Failed***
magic for 55 is 0000000000000000
***Failed***
magic for 56 is 0000000000000000
***Failed***
magic for 57 is 0000000000000000
magic for 58 is 0100020C08102001
magic for 59 is 0100008208100401
magic for 60 is 0100004820860405
magic for 61 is 0100004820860405
magic for 62 is 1100098250420021
magic for 63 is 0100028010200C41
Incidentally, do you know which of the multipliers are permuting the index bits and which are muddling them up completely?
And whether there is a fast numerical method of performing a particular bit permutation, other than a look-up table?
I suspect that many of the permutations generated by these magic numbers are identical and can be undone using the same inverse permutation.
0x0100040810204081ULL, // Rook 56 (14) 0xfe01010101010101 +0x0000000000000000
0x0900401012202409ULL, // Rook 57 (14) 0xfd02020202020202 +0x0000000000000000
0x0100020c08102001ULL, // Rook 58 (14) 0xfb04040404040404 +0x0000000000000000
magic occupancy bit relocation
0x0220006408012080ULL, // Rook 0 (14) 0x01010101010101fe +0x007f007f007f0000
0x0010010800000440ULL, // Rook 1 (14) 0x02020202020202fd +0x00ff00ff00020000
Square bit re-location magic
Rook 8 0x007F000000000000 0x84102000A0180680
Rook 9 0x007E000000000000 0x4086200048242040
Rook 10 0x007C000000000000 0x08001000101D0220
Rook 11 0x0078000000000000 0x4541000202880421
Rook 12 0x00F0000000000000 0x0800800304440208
Rook 13 0x0060000000000000 0x404300008141220D
Rook 14 0x0040000000000000 0x00070000E0804031
Rook 15 0x3F80000000000000 0x04208002C0A11209
//54
0x40bf404040404040
0100 0000 1011 1111 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000 0100 0000
0100000010111111010000000100000001000000010000000100000001000000
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
##############
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
k
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
n
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
##############
ajkmnphbicdefg
10
10a000000b
10a000000b0cdefgh0i000000
10a000000b0cdefgh0i0000000j0000000k0000
10a000000b0cdefgh0i0000000j0000000k0000000m0000000n00
0000000000010000000000000100000000000001000000000000001000000010
0000 0000 0001 0000 0000 0000 0100 0000 0000 0001 0000 0000 0000 0010 0000 0010
0x0010004001000202 magic
0a000000b0cdefgh0i0000000j0000000k0000000m0000000n0000000p000000
0000000000000000000000000001111111000000000111111100000000000000
0000 0000 0000 0000 0000 0000 0001 1111 1100 0000 0001 1111 1100 0000 0000 0000
0x0000001fc01fc000 relocate
uint64_t RookMagic[64] =
{
.....
0x018002c200040018ULL, // Rook 52 (14) 0x10ef101010101010 +0x000003f800380000
0x0000200080020004ULL, // Rook 53 (14) 0x20df202020202020 +0x00000fe00fe003e0
0x0010004001000202ULL, // Rook 54 (14) 0x40bf404040404040 +0x0000001fc01fc000
0x0000400080000201ULL, // Rook 55 (14) 0x807f808080808080 +0x00401f801f801f80
0x0100040810204081ULL, // Rook 56 (14) 0xfe01010101010101 +0x0000000000000000
.....
};
Bitboard BishopMagic[64] = // motion of piece up to obstacles
{
...
0X04001010006A0082ULL, // Partial Bishop 33 (9)
0X6014200800010024ULL, // Partial Bishop 34 (11)
0X3210002020080009ULL, // Partial Bishop 35 (13)
0X6100080200010009ULL, // Partial Bishop 36 (13)
0X408010C040060030ULL, // Partial Bishop 37 (11)
...
};
if (tempBitboard = (RooksQueens(them) & rookMask[kingSq])) {
index = (int)((tempBitboard * rookMagic[kingSq]) >> rookShift[kingSq]);
tempBitboard = *(rookIndecies[kingSq] + index) & AllOccupied;
index = (int)((tempBitboard * rookPinMagic[kingSq]) >> 50);
CheckOrPinned = *(rookPinIndieces[kingSq] + index);
}
Now I am wondering why I put the word "PARTIAL" in the comments here.
0X0020080200802009ULL, // Full Bishop 0 ( 7/ 8) 0x8040201008040201
0X0002040810204080ULL, // Full Bishop 1 ( 7/ 8) 0x0080402010080502
0X4040404040404040ULL, // Full Bishop 2 ( 7/ 8) 0x0000804020110a04
0X2020202020202020ULL, // Full Bishop 3 ( 7/ 8) 0x0000008041221408
0X1010101010101010ULL, // Full Bishop 4 ( 7/ 8) 0x0000000182442810
0X0808080808080808ULL, // Full Bishop 5 ( 7/ 8) 0x0000010204885020
0X0404040404040404ULL, // Full Bishop 6 ( 7/ 8) 0x000102040810a040
0X0202020202020202ULL, // Full Bishop 7 ( 7/ 8) 0x0102040810204080
0X0100040810204081ULL, // Full Bishop 8 ( 7/ 8) 0x4020100804020102
....
I'm afraid I don't see any advantage in including any extra bit for the square that the piece sits on.
Instead of adding an extra bit, try removing one. For example I have found seven 6-bit magics for the bishops.
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 8 guests