Author: Tom Kerrigan
Date: 10:16:45 02/11/00
Go up one level in this thread
On February 11, 2000 at 12:44:20, Daniel Karlsson wrote: >I use: > >WHITE = 0x10 >BLACK = 0x20 > >PAWN = 1 >etc... > >It's very convenient in some places as it only takes a bitwise and to find >friendly and enemy pieces. > >The only disadvantage I can think of is indexing arrays by color. What I like right now is: 0000 = EMPTY 0001 = WHITE PAWN 0010 = WHITE KNIGHT ... 1001 = BLACK PAWN 1010 = BLACK KNIGHT ... With this setup, you can compare the value to 0 to see if the square is empty. The following macros also work: #define COLOR(x) (x >> 3) #define TYPE(x) (x & 7) So, only one logic operation to get at the important stuff. And the COLOR macro returns either 0 or 1, so it's easy to use as an index. I think you're doing the same thing, except your color bit is #5 and not #4. I would prefer using #4 as the color bit because then you can use the 4 bits as an index to stuff, like hash key random numbers, i.e., __int64 hash_random[14][128]; There's some wasted space, but not very much. -Tom
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.