Author: Steffan Westcott
Date: 10:17:53 09/14/02
Go up one level in this thread
On September 14, 2002 at 12:41:02, Alessandro Damiani wrote: >On September 14, 2002 at 07:27:17, Steffan Westcott wrote: > >>BitBoard WhitePassedPawns(BitBoard w_pawns, BitBoard b_pawns) >>{ >> return w_pawns & ~FillDown( b_pawns >> | ShiftDownLeft (b_pawns) >> | ShiftDownRight(b_pawns)); >>} > >There is just a small improvement to your method "WhitePassedPawns()": factor >out the "shift down" to avoid shifting down twice. > >BitBoard WhitePassedPawns(BitBoard w_pawns, BitBoard b_pawns) >{ > return w_pawns & ~FillDown( b_pawns > | ShiftDown( ShiftLeft (b_pawns) > | ShiftRight(b_pawns)); >} > Alessandro, I should have also included the following procedure definitions. Note these diagonal shifts are about as fast as the rank and file shifts. So my original code _may_ be a very narrow win over yours, or your favourite optimising compiler may in fact give you the same object code for both! For clarity in my posts, I'm not writing 'inline' everywhere, please assume their presence as appropriate :) ---- CUT HERE ---- BitBoard ShiftUpRight(BitBoard b) { return (b<<9) & 0xfefefefefefefe00; } BitBoard ShiftUpLeft(BitBoard b) { return (b<<7) & 0x7f7f7f7f7f7f7f00; } BitBoard ShiftDownRight(BitBoard b) { return (b>>7) & 0x00fefefefefefefe; } BitBoard ShiftDownLeft(BitBoard b) { return (b>>9) & 0x007f7f7f7f7f7f7f; } ---- CUT HERE ---- Cheers, Steffan
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.