Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 0x88 board representation

Author: Matt

Date: 15:32:54 03/06/99

Go up one level in this thread


Ok, one more question... I have been told that there is some sort of
relationship with the bits that allows one to tell whether any two squares are
on a diaganol.  same row and same colum are easy, but I haven't yet been able to
work out what sort of binary operation one would do to two squares to tell if
they are on the same diaganol...  Here is the whole board in binary:


x000x000  x000x001 x000x010  x000x011 x000x100  x000x101 x000x110  x000x111
x001x000  x001x001 x001x010  x001x011 x001x100  x001x101 x001x110  x001x111
x010x000  x010x001 x010x010  x010x011 x010x100  x010x101 x010x110  x010x111
x011x000  x011x001 x011x010  x011x011 x011x100  x011x101 x011x110  x011x111
x100x000  x100x001 x100x010  x100x011 x100x100  x100x101 x100x110  x100x111
x101x000  x101x001 x101x010  x101x011 x101x100  x101x101 x101x110  x101x111
x110x000  x110x001 x110x010  x110x011 x110x100  x110x101 x110x110  x110x111
x111x000  x111x001 x111x010  x111x011 x111x100  x111x101 x111x110  x111x111


diaganols going /, r+c is constant...
diaganols going \, r-c is constant...

I haven't found an elegant way to check both of these though

if(((sq1&112)>>4)+(sq1&7)==((sq2&112)>>4)+(sq2&7)||((sq1&112)>>4)-(sq1&7)==((sq2&112)>>4)-(sq2&7))

would work i think, but thats pretty ugly.  Is there a better way?

Matt



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.