user21341: To make my engine more efficient, I am writing my engine such that it uses bit-boards in its move generation. But I have a question, suppose I have a rook move mask centered at a specific spot, how might I transpose the rook mask so that it shows the moves for a different position? eg:
from this mask:
[
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [1, 1, 1, "R", 1, 1, 1, 1],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0]
];

to this mask:
[
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [1, 1, 1, "R", 1, 1, 1, 1],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0]
];


If you need any clarifications regarding the question feel free to ask.

user9684: In the beginning, they thought that using a right shift (or a left shift), but they found that, as with other systems, bit would fall off the board.  To correct this, they computed every move from each square for each piece.  This takes a performance hit only when the page loads.  The other alternative they tried was to just load precomputed bitboards which increases the data slightly.
I've developed a system which has drawbacks including being slightly slower, but it's easier to understand.
First you need three arrays:
const int movement[64] ={

17171, 50075, 50075, 50075, 50075, 50075, 33179, 32905, 

18231, 51199, 59391, 59391, 59391, 59391, 41471, 41165, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20023, 24319, 32511, 32511, 32511, 32511, 14591, 12493,

 3110, 23662, 15470, 15470, 15470, 15470, 14446, 12364

};

const int dir[16] ={
    8, 1, -8, -1, 9, -7, -9, 7, 17, 10, -6, -15, -17, -10, 6, 15
};

const int key[16] = {
    1, 2, 4, 8, 16, 32, 64, 128,
    256, 512, 1024, 2048, 4096, 8192, 16384, 32768
};

This is constructed so that if the first bit (key[0]) is set, then the relative movement of +8 (dir[0]) is possible;  (Showing this in hex would display the relative values better.)
The move generation is six functions each containing about 9 lines each.  The bitboard generation is shorter and faster, but harder to implement.  Using magic bitboards is even faster, but it's even harder to understand.

21341: <p>To make my engine more efficient, I am writing my engine such that it uses bit-boards in its move generation. But I have a question, suppose I have a rook move mask centered at a specific spot, how might I transpose the rook mask so that it shows the moves for a different position? eg:</p>

<pre><code>from this mask:
[
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [1, 1, 1, "R", 1, 1, 1, 1],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0]
];

to this mask:
[
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [1, 1, 1, "R", 1, 1, 1, 1],
    [0, 0, 0, 1, 0, 0, 0, 0],
    [0, 0, 0, 1, 0, 0, 0, 0]
];

</code></pre>

<p>If you need any clarifications regarding the question feel free to ask.</p>
 9684: <p>In the beginning, they thought that using a right shift (or a left shift), but they found that, as with other systems, bit would fall off the board.  To correct this, they computed every move from each square for each piece.  This takes a performance hit only when the page loads.  The other alternative they tried was to just load precomputed bitboards which increases the data slightly.</p>

<p>I've developed a system which has drawbacks including being slightly slower, but it's easier to understand.</p>

<p>First you need three arrays:</p>

<pre><code>const int movement[64] ={

17171, 50075, 50075, 50075, 50075, 50075, 33179, 32905, 

18231, 51199, 59391, 59391, 59391, 59391, 41471, 41165, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20279, 57343, 65535, 65535, 65535, 65535, 45567, 45261, 

20023, 24319, 32511, 32511, 32511, 32511, 14591, 12493,

 3110, 23662, 15470, 15470, 15470, 15470, 14446, 12364

};

const int dir[16] ={
    8, 1, -8, -1, 9, -7, -9, 7, 17, 10, -6, -15, -17, -10, 6, 15
};

const int key[16] = {
    1, 2, 4, 8, 16, 32, 64, 128,
    256, 512, 1024, 2048, 4096, 8192, 16384, 32768
};
</code></pre>

<p>This is constructed so that if the first bit (<code>key[0]</code>) is set, then the relative movement of <code>+8</code> (<code>dir[0]</code>) is possible;  (Showing this in hex would display the relative values better.)</p>

<p>The move generation is six functions each containing about 9 lines each.  The bitboard generation is shorter and faster, but harder to implement.  Using <a href="https://www.chessprogramming.org/Magic_Bitboards" rel="nofollow noreferrer">magic bitboards</a> is even faster, but it's even harder to understand.</p>
