Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 0x88 board representation

Author: Jonathan Goldstein

Date: 00:15:09 03/06/99

Go up one level in this thread


On March 05, 1999 at 22:31:51, Matt wrote:

>On March 05, 1999 at 21:09:11, Bruce Moreland wrote:
>
>>
>>On March 05, 1999 at 18:42:51, Matt wrote:
>>

>I am not sure how you would use this to see if its possible to get from one
>square to another.  ie. if you are calculating moves for a bishop, one of the
>offsets is -9... if you hit a2 -9, you hit h1, so how does the bounds checking
>work in this case?
>
>>bruce
>
>Matt

The bishop would have an offset of -9 in the 64 square representation, but in
the 128 square representation, the four bishop offsets would be:

     + n*17 (up-right)
     + n*15 (up-left)
     - n*17 (down-left)
     - n*15 (down-right)

where where n is an integer, and 0 < n < 8, with appropriate bounds checking.

So for a2 (16), going down-left one would be (16 - 17) = 255 which would
fail the 0x88 check (see below).  Going down-right one from a2 would be
16 - 15 = 1, which is b1, the correct square.

255 fails because:

      255 = 11111111b
   & 0x88 = 10001000b
=    0x88 = 10001000b (result not zero, so invalid square)

An example of a square the doesn't fail:

d5 = 67:

       67 = 01000011b
   & 0x88 = 10001000b
=       0 = 00000000b

-Jon




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.