Reinhard Scharnagl wrote:In ancient days, where memory had been expensive, I did it, too. Actually there are some castling relevant data fields to support e.g. Chess960. Also notice the two root fields for my two color specific double linked sorted piece lists consisting of the existing board pieces.
Actually, I consider memory exactly as expensive as it used to be when I was writing chess codes 20 years ago. I want my program to run (almost) exclusively from the L1 cache. And this is similar in size (32-64KB) to the address space of the 8-bit CPUs of those days...
The only advantage I take from the huge memory sizes is that now I can afford transposition tables and end-game table bases. But access to those is still outrageously expensive, on my Celeron a random hit in DRAM (most likely causing also a DRAM page miss and a TLB miss) takes 351 CPU clocks (27 FSB clocks) to process (if the flushed cache block was clean!). The latency is somewhat smaller, but the throughput limits hash-table lookups to ~4M per second.
Alessandro Scotti wrote:H.G.Muller wrote:The low-bit = square color I had not realized. Great trick! And yet another argument in favor of this representation.
As Reinhard said, it's not used very often though. In Kiwi (which has a standard 8x8 board for this stuff), I have this code:
- Code: Select all
inline int color_of( int sq ) {
return (sq + (sq >> 3)) & 1;
}
so it's not much more expensive. I use it only in the KBBK and KBNK recognizers so far.
I use the square-color test a lot in my end-game table-base generator. When it is generating retrograde moves, it has to take account of the fact that the move might have been a capture, and leave behind any of the pieces currently in custody on the square it 'came from' (besides leaving it empty). If a Bishop or other color-bound piece is amongst the captured pieces, I want to put it back only on the color it belongs.