Author: James Robertson
Date: 14:20:38 06/17/99
Go up one level in this thread
On June 17, 1999 at 14:44:19, Edward Screven wrote: Thanks! I will save this code and go through it carefully. James >On June 17, 1999 at 00:10:11, James Robertson wrote: > >>I am trying to find the most efficient way to detect backward pawns, either with >>bitboards or the more conventional piece array. Any help is greatly >>appreciated!! >> >>James > >if bitboards are useful anywhere, it has to be calculating >pawn structure information. here's how i calculate backward >pawns. my definition is a little different than yours, but >it could easily be made the same. > >here's how i calculate the set of squares attacked by white >pawns. "Squares" is a 64-bit unsigned integer; "wpawns" >are the squares occupied by white pawns. > > inline static Squares WhiteAttacks(Squares wpawns) > { > return (((wpawns & ~FILE_A) << 9) | > ((wpawns & ~FILE_H) << 7)); > } > > >WhiteWeak() returns white's weak pawns. "apawns" are the >squares occupied by white or black pawns. "wattacks" are >squares attacked by white pawns before any pawn moves. i >consider a pawn weak if it isn't defended by a pawn, or >can't be defended after one pawn move. > > inline static Squares WhiteWeak(Squares wpawns, > Squares apawns, > Squares wattacks) > { > /* > ** a pawn is weak if > ** > ** 1) it is not currently defended > ** 2) it cannot be pushed onto a defended square > ** 3) it cannot be double-pushed onto a defended square > */ > > Squares weak = wpawns; > > weak &= ~wattacks; > weak &= ~((wattacks & ~apawns) >> 8); > weak &= ~(((wattacks & ~apawns & ~(apawns << 8)) >> 16) > & RANK_2); > > /* > ** and if > ** > ** 4) a pawn cannot be pushed to defend it > ** 5) a pawn cannot be double-pushed to defend it. > */ > > Squares wstep1 = (wpawns << 8) & ~apawns; > Squares wstep2 = (wstep1 << 8) & ~apawns & RANK_4; > > weak &= ~WhiteAttacks(wstep1 | wstep2); > > return weak; > } > > >finally we get to backward pawns. i consider a pawn backward >if it is weak and the square in front of it is attacked by >an enemy pawn, and the square is occupied by another pawn. > > inline static Squares WhiteBackward(Squares wweak, > Squares apawns, > Squares battacks) > { > return wweak & ((~apawns & battacks) >> 8); > } > > >i use similar kinds of code to calculate isolated and passed pawns. > > - edward
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.