Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Portability and Readability and compilers are most important in software

Author: Sune Fischer

Date: 04:08:36 10/24/03

Go up one level in this thread


On October 23, 2003 at 22:24:38, Vincent Diepeveen wrote:

>On October 23, 2003 at 20:29:24, Sune Fischer wrote:
>
>>>
>>>What i also do avoid in diep is writing out code for black and white. I have
>>>neat loops there where easily possible:
>>>  for( side = 0 ; side <= 2; side++ )
>>
>>Pawns always break symmetry anyway, so it doesn't work 100%.
>
>Not sure whether there's already snow falling in your country, hiding the shape
>of the board, but mine is 8x8, so that's mirrorable in 2 ways at least.
>
>So with a bit of good coding 1 pattern can be used 4 times here and you write
>down it 4 times.

I was thinking about pawns moving in one direction, but I guess you can just
throw in an extra signed variable to flip flop.

>Good luck.
>>
>I do use defines indeed.
>
>However i'm not toying with assembly code in DIEP like you are. I prefer to
>spend my time elsewhere than that.
>
>Good luck writing Itanium assembly by the way :)

Um, first things first here.
I was suggesting that you used a macro like:

#define isPcOfColourOnSq(p,c,s) (board[s]==(p) && color[s]==(c))

No assembly required :)

If you really need this a lot, wouldn't it be better to test using bitpatterns?
You would be able to do multiple checks at a time with a pattern, ie.
{white_pawns,black_pawns,white_knights,black_knigths,..={10,11,100,101,1000,1001,
etc...} (<= as bits not hex)

You can check for color, multiple type of piece at the same time, like

#define black_rook_or_queen (1100001) // enables single check for black rook or
queen


Okay, now the assembly issue, guess you are refering to firstone() of Crafty?
First let me broaden your horizon a bit and tell you that assembly has an
alternative, namely C/C++.

I have two versions, one table driven C version and an x86 optimized assembler
version. They are very close in speed, the table version is slightly faster on
my athlon XP and the assembly a few percent faster on my notebook, a Celeron
900. I guess the cache gets trashed too much with a 16k table on the Celeron,
but caches get bigger and new doors open :)

For portability I simply use the C version (again macros rule!).

Happy bitboarding,
-S.



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.