I'm trying to understand how works bitboard representation in chess programming and I can't find usefull information (or just can't translate it correctly ^^) about one detail. My question is, how to generate automaticly masks for move on every position by every piece. I assume its an matrix where each piece type have define every field he can move from this position (array[5][64] for wP, bP, K, R, N, B). For example for Rook on position below, only allowed positions are:
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
1 1 R 1 1 1 1 1
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0
I assume i have to create something like this for each piece type and for every tile it can step but do i have to hardcoded it manually to array or there is some possibility to automatize this process and precompute it after program run?
You could fairly easily precompute all of the bitboards that you need, since the rules of chess are well defined. For example, here is a function (in python) that would compute legal moves for a rook:
Instead of printing out the bitboard, you would likely store it in a compact format, such as an array of 64 bit values (since an 8x8 board needs 64 bits for each board).
This is a fairly extreme optimization technique, so the details of its implementation are going to get hairy (and be a pain to debug).
I used the wiki bitboard page as reference.