Computer Chess Club Archives


Search

Terms

Messages

Subject: 0x88 fast move generation

Author: Jan

Date: 04:35:14 01/17/04


Hi, im new to chess programming...i read some posts about 0x88 move generation
on this forum(by moreland and others) but im not able to make move generation
considerably fast. Could you give me some suggestions?

so i have: 128 array of bytes representing the board(0-5white
pieces,6-empty,7-12black pieces), lists of pieces(static allocated arrays
separated for every piece, which I can access later for example in make/unmake
via something like int *Pieces[]={WPawns,WKnights,...,BPawns})
my move structure is a 32bit int:
1bit:normal from-to move?
for typical move:
4bits:piece to move
4bits:captured piece
7bits:from
7bits:to

i do something like this:
int knightMoves[]={31,33,14,18,-31,-33,-14,-18,0};
int rookMoves[]={16,-16,1,-1,0};

void MoveGen(MOVE *first) {
int x,z,*y;
BYTE i;
if (sideToMove==white) {
//////////for pawns, this is terribly slow, as there are lots of ifs, but dont
know what to do with it
for (i=0;i<numberOfWPawns;i++) {
x=WPawns[i];
if (!((x+16)&0x88) && pos[x+16]==EMPTY) if (x<88)
first++=WHITE_PAWN_MOVE|x<<9|(x+16)<<16; else GeneratePromotion;
....and so on for x+15 and x+17(captures), which means also another xor of
poz[x+15(17)]<<5;
}

/////////for knight it looks simple, but it's slow as well :)
for (i=0;i<numberOfWKnights;i++) {
x=WKnights[i];
for (y=knightMoves;*y;y++) {
z=x+*y;
if ((!(z&0x88)) && pos[z]>=6) *first++=WHITE_KNIGHT_MOVE|pos[z]<<5|x<<9|z<<16;
}
}
/////////for rook
for (i=0;i<numberOfWRooks;i++) {
x=WRooks[i];
for (y=rookMoves;*y;y++) {
z=x+*y;
while ((!(z&0x88)) && pos[z]>=6) {
*first++=WHITE_ROOK_MOVE|pos[z]<<5|x<<9|z<<16;
if (pos[z]!=EMPTY) break;
z+=*y;
}}}}}

Huh, hope i didnt make many mistakes when rewriting it. And plz, when you give
me some advice, make it as clear as possible, im not very skilled in this. :)



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.