Andscacs - New version

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
fern
Posts: 8755
Joined: Sun Feb 26, 2006 4:07 pm

Re: Andscacs - New version

Post by fern »

Maybe I saw what you did not put there.
No, seriously I had that impression.
Maybe I am wrong.
If so, forgive me.

Viva Cataluña libre de los coños!
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Andscacs - New version

Post by cdani »

Well. If someone sees anything not translated, just tell me. I will translate immediately. From the start my objective was that all the people can understand what I publish, I’m pragmatic. I put all also in Catalan just because it’s my language. And yes, it’s the primary language in Andorra.

And I don’t tell anything about Catalunya because it’s not related in any way.

After this little misunderstanding, I get back to chess.
Gerd Isenberg wrote: * Faster calculation of piece attacks. No need any further of rotated bitboards.
Hi Daniel,
can you elaborate a bit on how you generate sliding attack bitboards?
Do you use incremental updated attack tables, i.e. attacksFrom[64]?
Gerd
Sure I can!
I translated :-), as I said, the code.
This is the basic idea:

Code: Select all

if (BitScanForward(&indexbit, PreCalcRook[square].BitboardRookGoesUpFromThisSquare & position->AllThePieces)) {
		*AttacksOfPiece |= PreCalcRook [square]. BitboardRookGoesUpFromThisSquare & RowsAt1FromRow0ToRow [ROW(indexbit)];
	} else {
		* AttacksOfPiece |= PreCalcRook [square]. BitboardRookGoesUpFromThisSquare;
	}
 
So, with a precalculated bitboard of the squares where the rook will go to every direction, I search the first, if any, square where there is any piece of any color. If there is one, I use the same precalculated bitboard and I mask it with a bitboard like this:
00000000
00000000
00000000
11111111
11111111
11111111
11111111
11111111
With this I obtain the bitboard of attacks.
This is done in every 4 directions.
The same it’s used for Bishops/Queens.

I use a little optimization more. For the horizontal attacks of the rook/queen, I can use:

Code: Select all

Bytes_AttacksOfPiece [ROW(square)]=AttacksRow[COL(square)][Bytes_AllThePieces[ROW(square)]];
So I can put the attacks of the two horizontal directions in one line of code. AttacksRow is a precalculated array of bytes that contains the attacks that a rook in the column of the first dimension will do if the pieces in this row are put like the byte that goes to the second dimension.
So, Bytes_AttacksOfPiece and Bytes_AllThePieces, are array of bytes that share the same memory of the bitboards AttacksOfPiece and AllThePieces. Obviously this cannot be done for vertical or diagonal movements.

All this is a little improvement for what I had before. I know this is not very nice and I suppose it’s slower than magic bitboards, but the idea is to put magic bitboards when I understand them, and I did not used time for this for the moment.
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: Andscacs - New version

Post by Gerd Isenberg »

cdani wrote:
Gerd Isenberg wrote: * Faster calculation of piece attacks. No need any further of rotated bitboards.
Hi Daniel,
can you elaborate a bit on how you generate sliding attack bitboards?
Do you use incremental updated attack tables, i.e. attacksFrom[64]?
Gerd
Sure I can!
I translated :-), as I said, the code.
This is the basic idea:

Code: Select all

if (BitScanForward(&indexbit, PreCalcRook[square].BitboardRookGoesUpFromThisSquare & position->AllThePieces)) {
		*AttacksOfPiece |= PreCalcRook [square]. BitboardRookGoesUpFromThisSquare & RowsAt1FromRow0ToRow [ROW(indexbit)];
	} else {
		* AttacksOfPiece |= PreCalcRook [square]. BitboardRookGoesUpFromThisSquare;
	}
 
So, with a precalculated bitboard of the squares where the rook will go to every direction, I search the first, if any, square where there is any piece of any color. If there is one, I use the same precalculated bitboard and I mask it with a bitboard like this:
00000000
00000000
00000000
11111111
11111111
11111111
11111111
11111111
With this I obtain the bitboard of attacks.
This is done in every 4 directions.
The same it’s used for Bishops/Queens.

I use a little optimization more. For the horizontal attacks of the rook/queen, I can use:

Code: Select all

Bytes_AttacksOfPiece [ROW(square)]=AttacksRow[COL(square)][Bytes_AllThePieces[ROW(square)]];
So I can put the attacks of the two horizontal directions in one line of code. AttacksRow is a precalculated array of bytes that contains the attacks that a rook in the column of the first dimension will do if the pieces in this row are put like the byte that goes to the second dimension.
So, Bytes_AttacksOfPiece and Bytes_AllThePieces, are array of bytes that share the same memory of the bitboards AttacksOfPiece and AllThePieces. Obviously this cannot be done for vertical or diagonal movements.

All this is a little improvement for what I had before. I know this is not very nice and I suppose it’s slower than magic bitboards, but the idea is to put magic bitboards when I understand them, and I did not used time for this for the moment.
I see, thanks for the explanation - I am a sliding piece algorithm collector ;-)

Your one is good and much more memory friendly than magics and its your own one.

I guess this one is most similar (except xor):
https://chessprogramming.wikispaces.com ... l+Approach
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Andscacs - New version

Post by cdani »

Gerd Isenberg wrote: I guess this one is most similar (except xor):
https://chessprogramming.wikispaces.com ... l+Approach
Aha! I did not think about this xor trick :-) Nice.
Jamal Bubker
Posts: 326
Joined: Mon May 24, 2010 4:32 pm

Re: Andscacs - New version

Post by Jamal Bubker »

Thank you Daniel for this new release !