Author: Maurizio Di Vitto
Date: 06:50:34 12/12/03
Dear Mr Wegner,
Thank you for your explanation, it was very clear and I solved all the problem.
I am going to write code about diagonals moves, so I know I need a 45° rotated
bitboard, before I start thinking about how to improve that I’d like to show you
how I represent the chessboard:
63 62 61 60 59 58 57 56
55 54 53 52 51 50 49 48
47 46 45 44 43 42 41 40
39 38 37 36 35 34 33 32
31 30 29 28 27 26 25 24
23 22 21 20 19 18 17 16
15 14 13 12 11 10 9 8
7 6 5 4 3 2 1 0
a1 b1 c1 d1 e1 f1 g1 h1
the 90° rotatedbitboard should work well:
int rotated90r[64]={7,15,23,31,39,47,55,63,
6,14,22,30,38,46,54,62,
5,13,21,29,37,45,53,61,
4,12,20,28,36,44,52,60,
3,11,19,27,35,43,51,59,
2,10,18,26,34,42,50,58,
1,9, 17,25,33,41,49,57,
0,8, 16,24,32,40,48,56
};
the 45° rotated bitboard should look like this (for now I care about a1-h8
diagonal):
Rotated45[64]
63 55 62 47 54 61 39 46
53 60 31 38 45 52 59 23
30 37 44 51 58 15 22 29
36 43 50 57 7 14 21 28
35 42 49 56 6 13 20 27
34 41 48 5 12 19 26 33
40 4 11 18 25 32 3 10
17 24 2 9 16 1 8 0
then I need an array to calculate the number of state about a diagonal
(2^state_index[square]):
int state_index[64] = {
1,2,3,4,5,6,7,8,
2,3,4,5,6,7,8,7,
3,4,5,6,7,8,7,6,
4,5,6,7,8,7,6,5,
5,6,7,8,7,6,5,4,
6,7,8,7,6,5,4,3,
7,8,7,6,5,4,3,2,
8,7,6,5,4,3,2,1 };
then I need another array to know how many unit I have to shift, It would look
like:
shift_index[64]={ 0, 1, 3, 6, 10, 15, 21, 28,
1, 3, 6, 10, 15, 21, 28, 36,
3, 6, 10,15, 21, 28, 36, 43,
6, 10,15,21, 28, 36, 43, 49,
10,15,21,28, 36, 43, 49, 54,
15,21,28,36, 43, 49, 54, 58,
21,28,36,43, 49, 54, 58, 61,
28,36,43,49, 54, 58, 61, 63
};
so I would write something like that:
for (square=0; square<64; ++square)
{
for (state=0; state=2^state_index[square]; ++state)
{
keep_value=state<<shift_index[square];
//What’s the best way to refer to the square. I
//mean:
//example: square=14(the main diagonal a1-h8)
//I need to shift left and right to the 45° rotated bitboard,
//How can I find the index of the square number 14 to the
//45° rotated bitboard. I thought about another array
//where I can control the right index, but it doesn’t
//seem the right solution.
}
}
Am I on the right way?
Big Thanks again.
Maurizio Di Vitto.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.