Author: Vincent Diepeveen
Date: 07:53:25 12/17/02
Go up one level in this thread
On December 17, 2002 at 09:40:21, JW de Kort wrote: >On December 17, 2002 at 08:56:24, Vincent Diepeveen wrote: > >>On December 17, 2002 at 04:15:26, JW de Kort wrote: >> >>I do not understand why you want to change it to something >>slower. >> >>0x88 is fine. >> >>also fine is the gnuchess 4.0 datastructure >> >>int piecelist[2][18]; // containing squares of the pieces >>int piececnt[2]; // number of pieces minus king as you have that one anyway >> >>and at the end of the squares where the pieces are, you put a -1 or >>whatever that speeds up the loop a lot. >> >>int board[64]; // 0..6 empty,pawn,knight,bishop,rook,queen,king >>int color[64]; // 0,1,2=neutral >>int quickboard[64]; // 0..12 same as board also bpawn,bknight,bbishop,brook ... >>int pindex[64]; // two times 0..15 giving index in piecelist >> >>this very simple datastructure allows manipulations to be done very quick. >> >>For example if you move from a1 to a2, then all you gotta do is >> index = pindex[a2] = pindex[a1]; >> board[a2] = board[a1]; >> board[a1] = 0; >> quickboard[a2] = quickboard[a1]; >> quickboard[a1] = 0; >> piecelist[side][index] = a2; >> >>You can do that tens of millions of times a second. >> >>>Hi, >>> >>>Currently i'am using a piecelist to keep track of the locations of the pieces in >>>my 0x88 based program. Iám thinking about removing this list and replacing it by >>>a bitboard to keep track of the piecelocations of white pieces and black pieces. >>>I'am wondering of anybody else does this (i think some one will) and if this is >>>a good improvement to spees up my engine which is terrably slow. I have good >>>expierences with other bitboards in my program. I already use bitboard to do the >>>pawn evaluations and i'am thinkin about gradually removing the 0x88 stuff to >>>replace it with bitboards >>> >>>any help appreciated >>> >>> >>>Regards >>> >>>Jan Willem > > >Thats true but what i find very difficult is loping alon all pieces eg when >evaluating and removing a captured piece from thet piecelist. I have to do >something lik > >piecelist[sq[to]]=EMPTY you should not reference arrays in arrays but use more local variables instead. That goes way quicker! >and i wondered if a bitboard would speed up matters. Not at all, especially not at 32 bits processors. And i doubt you have your own McKinley system so most likely you are 32 bits :) >In evaluation i do something like > >while (!lLASTPIECE) > if (piecelist[i] !=EMPTY) > evaluate that's again easy to improve in 2 ways. First of all is using do .. while, instead of a while. though most compilers will translate it to a 'do .. while' (i hope) the processors are having in general a fall through principle which works great. Secondly use a local variable to replace that piecelist[i]. >and i wonderded if this could be speed uop by using a bitboard. Not at all. bitboards are meant for 64 bits processors and comparing them at 32 bits processors is not only not fair it is also a quickly run race. Factor 2.2 is what i measure in speed difference. But improving programming isn't a bad idea in general when i look to the above code. Best regards, Vincent
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.