Author: José Carlos
Date: 16:01:02 02/19/04
Go up one level in this thread
On February 19, 2004 at 18:58:47, José Carlos wrote: >On February 19, 2004 at 16:57:39, Tim Foden wrote: > >>On February 19, 2004 at 14:39:16, Uri Blass wrote: >> >>>Today I have an array direction[64][64] that gives me different numbers for >>>different directions(possible directions are queen direction that get 0-7 knight >>>directions that get -2,identical squares that get -9 or no direction that gets >>>-1 ). >>> >>>I thought about the idea to change it to the following definition: >>> >>>#define direction((i)(j)) directionnumber[translate[i]-translate[j]+128] >>> >>>The result is that I can get instead of one array of 4096 entries >>>2 arrays when translate is an array of 64 entries and directionnumber is an >>>array of 256 entries. >>> >>>My question is if it is a good idea from speed point of view. >>>It will probably be a simple change when I only need to construct the 2 arrays >>>and the main problem is to construct the translate array. >>> >>>It is probably only few hours of work but I do not like to spend time on >>>constructing these arrays only to discover later that it is not productive so I >>>ask for your opinion about it. >>> >>>Uri >> >>If you converted the coordinates to 0x88 coordinates, you only need a 256 byte >>lookup table. >> >>A macro to do the conversion from the 64 square system would be... >> >>#define TO88(sq) ((sq) + ((sq) & 0x38)) > > Hi Tim. Your conversion is probably faster than mine. Here's the best I could >figure out (in Averno): > >#define Trad0x88(x) ((((x)&120)<<1)|((x)&7)) // 64 -> 0x88 >#define Trad64(x) (((x&240)>>1)|(x&7)) // 0x88 -> 64 Sorry, there must be a pair of brackets around x: #define Trad64(x) ((((x)&240)>>1)|((x)&7)) // 0x88 -> 64 José C. > I don't even remember how I came to them (trying out in paper, I think). I >also recall I tried building a conversion array, but it turned out to be clearly >slower. > > José C. > > >>So you could then use... >> >>#define direction(i, j) (directionNumber[(TO88(i) - TO88(j)) & 0xFF]) >> >>Cheers, Tim.
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.