Author: Sune Fischer
Date: 10:31:22 01/10/04
Go up one level in this thread
On January 10, 2004 at 12:29:32, Maurizio Di Vitto wrote: >Dear Mr Fischer, >thank you very much for your help. Maybe the question about the shift was not so >clear. I'll try to explain better. >Let's have an example, let's take the +9 movement that should be the up left >movement and let's start from the square number h1, I mean the bit number 0 >(..... 00000000 00000001). That code is using a different board orientation, a1 is square 0, h1 is square 7... h8 square 63. This is the easiest to use I think, this way a1 gets to be the 0'th rank and 0'th file. If you want to use something different the tables must be initialized in a different way. Another way I could find tempting is to use a8 = 63 and a1 = 0. This makes for a better reflection symmetry, but it's not so easy to work with (mentally) perhaps. > If we look to the shiftR45 table we'll find that the >index is 1 (shiftR45[0]). So we have 0 9 18 27 ..., if we find RotatedR45[9], >RotatedR45[18] etc. we'll have teh fallowing b1 c1 d1 ... that mean 1 2 3, and >if we shift them of 1 unit we will have 1>>1(this bit is out) 2>>1 3>>1 .., ... >00000000 01111111, so we have seven bit. It's supposed to be all wrong, could >you explain my mistakes. The diagonal attacks are a real mess for sure. You just take a board and lay down the diagonals so we can shift them out like a row. There are a hundred ways that can be done, you just have to make a "how much to shift" table to decode the transformation, and of course fill the attack table correctly. I don't remember the exact transformation any more, but it's something like a1->a1, b2->b2,c3->c1 etc to get the long diagonal down. Then the others are just shuffled into place however it is possible, a2->a2,b3->b2,...,g8->g2 now h2 is left over to contain a diagonal of length 1, so we use e.g. a8->h2. The the same with the other diagonals rotated in the other direction. >Then I don't understand why you use the A column in the right side of the >chessboard. There probably is no logical reason why that is so, it just happened to fit like that. >Another two things, what COMPACT_ATTACK_TABLES is and in the rook routine you >use ((1<<i)&(bitrow<<1)) to control if the rook meet a piece or a bit, but why >this? The (1<<i) is setting the i'th bit, so what the loop does is a scan in each direction from the location of 'file' to see when it encounters a bit of the attack status. When that happens, it means it has found an obstacle and it does not do any attacks from that point on, so it breaks out of the loop. It's basicly a form of raytracing using bits, for instance if bitrow = x100111x (occupied 6 bit rank) file = 5 = 00001000 (file of the our location) final attack row 01110100 (this is what our attack rank will look like) So you can see how it must work, you start at bit 5+1 and trace until you bump into a bit, then you start a new scan from bit 5-1 until you bump into a bit. It's easier to work with these things on paper, than "seeing" it in the code. -S. >Thanks again for your time and help. >Maurizio Di Vitto
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.