Author: Scott Gasch
Date: 14:56:29 01/22/02
Go up one level in this thread
On January 22, 2002 at 17:02:00, Russell Reagan wrote: >Now a brief tangent about 0x88. This doesn't seem to work for all squares. >Perhaps someone can explain this to me. If you go to square 112 (A8 I belive), >and you want to generate the rook's legal moves, so you test 112+16 to see if >the rook can move up one square on the board, but 112+16=128, which is out of >bounds of the 8x16 array, so detecting the edge for the top row doesn't work. I >suppose you could simply add rows to the top and bottom and have a 11x16 array >to handle this case, but I've always heard people using 8x16. So I either don't >understand something or something doesn't work right. I'm betting on me not >understanding something :) The idea with 0x88 is that a board coordinate is one byte. 4 of the bits are the row and 4 of the bits are the column. For example square g4 might be 0x31 (row 3, file 1). h1 might be 0x00 (row 0, file 0). The name 0x88 comes from the fact that if you have coordinates set up this way any byte with an asserted 0th or 4th bit is off the board. So if h1 is 0x00 and you subtract 0x10 (16) from it you will end up with 0xF0. And that with 0x88 to see if either the 0th or 4th bits is asserted: 0xF0 & 0x88 != 0x00 (it's = 0x80). Therefore that coord is off the board. So you can easily check if a coord is on board or not with 0x88. The deltas between squares are fixed (+/- 16 is vertical, +/- 1 is horizontal, +/- 15 and 17 are diagonal). You don't use a bunch of space like between 0x8..0xF etc... But you can use that space -- its often in the processor cache. See if you can think of anything to fill it with. Maybe Bruce will post his well-worn email about 0x88 again. I found it very helpful when I was starting out writing an engine based on this board representation. Scott
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.