Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitboards generate moves King, Knight

Author: Russell Reagan

Date: 12:07:33 09/21/04

Go up one level in this thread


On September 21, 2004 at 06:57:37, Gerd Isenberg wrote:

>>enum { white, black };
>>
>>// pawn moves forward
>>pawnMoves = (pawns << 8) >> (16 * side);

>Yes, this "generalized" shift by one rank works well for pawns, because they
>don't occupy first or eight rank.
>
>BitBoard pawnPushTargets(BitBoard pawns, int side) {
>  return (pawns << 8) >> (16 * side);
>}
>
>What about left and right pawn attacks with this trick?

Maybe something like this? I didn't have time to test it right now.

enum { white, black };

// For this function, left means left from white's point of view.
// Examples of pawn attacks left: e4d5 for white
//                                e4d3 for black

Bitboard PawnAttacksLeft (Bitboard pawns, int side)
{
    return ((pawns << 7) >> (16 * side)) & notFileH;
}



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.