Author: Sean Empey
Date: 15:21:38 08/12/04
Go up one level in this thread
On August 12, 2004 at 16:00:15, Stuart Cracraft wrote:
>On August 12, 2004 at 14:31:31, Sean Empey wrote:
>
>>On August 12, 2004 at 13:45:08, Jan K. wrote:
>>
>>>Hi, is there anyone who uses 0x88, 16x16 or similar type of board representation
>>>and is generating attack tables from scratch every time when needed? I didn't
>>>need full attack tables before, now I compute data about number of attacks and
>>>attackers like it's mentioned at ed schroder's web pages. On Athlon1800 from
>>>starting position i can generate the attack tables more than 2m times per
>>>second. After d4,d5,e4,e5 around 1600000x. The procedure is written in the most
>>>straightforward way and maybe there's chance for future optimization, but if
>>>someone gets twice more it's bad. :) Thanks for reply.
>>
>>I have a version of 0x88 that does have something like this. I build them on
>>initializitization then update them from that point on. Mine is very fast.
>>
>>
>>-Sean
>
>Does anyone know of a good pedantic source code somewhere?
I don't mind posting some old code I found of mine but I kind of misread the
original topic but here it is. Hope it's helpful for someone.
#include "data.h"
/*
* Function: Initialize
* Purpose: Initialize board and variables for new game
* Usage: N/A
* Version: See ExtVerInfo
*/
void Initialize( void ) {
int i, n, j, p, sq, z;
for ( i = 0; i < 128; i++ ) {
MainBoard.Color[i] = InitColor[i];
MainBoard.Piece[i] = InitBoard[i];
MainBoard.Pindex[i] = InitPindex[i];
}
for ( i = 0; i < 2; i++ ) {
for ( n = 0; n < 32; n++ ) {
MainBoard.PieceLst[i][n] = InitPieceLst[i][n];
}
}
MainBoard.stm = WHITE;
MainBoard.ep = -1;
//pre-compute KING and KNIGHT moves
for ( i = 0; i < 2; i++ ) { //0 = KING, 1 = KNIGHT
for ( n = 0; n < 128; n++ ) {
for ( j = 0; j < 10; j++ ) {
KNPreGen[i][n][j] = STOP;
if ( j > 7 || ( n & 0x88 )) continue;
sq = n;
if (i == 0 ) sq += KingOffset[j];
else sq += KnightOffset[j];
if ( sq & 0x88 ) continue;
else KNPreGen[i][n][j] = sq;
//printf("From: %d To: %d\n",n,sq);
}
z = -1;
for ( p = 0; p < 10; p++) {
if ( KNPreGen[i][n][p] == STOP && ( p <= z || z == -1 ) ) {
z = p;
}
if ( KNPreGen[i][n][p] != STOP && z != -1 ) {
if ( p > z ) {
KNPreGen[i][n][z] = KNPreGen[i][n][p];
KNPreGen[i][n][p] = STOP;
p = z;
z = -1;
}
}
}
}
}
//Pre-compute QUEEN, ROOK, BISHOP Moves
for ( i = 0; i < 3; i++ ) {
for ( n = 0; n < 128; n++ ) {
for ( j = 0; j < 32; j++ ) {
QRBPreGen[i][n][j] = STOP;
}
}
}
//Pre-compute QUEEN, ROOK, BISHOP Moves
for ( i = 0; i < 3; i++ ) {
for ( n = 0; n < 128; n++ ) {
if ( n & 0x88 ) continue;
j = 0;
switch ( i ) {
case 0 : //QUEEN
for ( z = 0; z < 8; z++ ){
QRBVector[i][n][z] = j;
for ( sq = n;; ) {
sq += QueenOffset[z];
if ( sq & 0x88 ) {
QRBPreGen[i][n][j] = STOP;
j++;
break;
}
QRBPreGen[i][n][j] = sq;
j++;
}
}
break;
case 1: //ROOK
for ( z = 0; z < 4; z++ ){
for ( sq = n;; ) {
sq += RookOffset[z];
if ( sq & 0x88 ) {
QRBPreGen[i][n][j] = STOP;
j++;
break;
}
QRBPreGen[i][n][j] = sq;
j++;
}
}
break;
case 2: //BISHOP
for ( z = 0; z < 4; z++ ){
QRBVector[i][n][z] = j;
for ( sq = n;; ) {
sq += BishopOffset[z];
if ( sq & 0x88 ) {
QRBPreGen[i][n][j] = STOP;
j++;
break;
}
QRBPreGen[i][n][j] = sq;
j++;
}
}
break;
}
}
}
}
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.