Pawns+and+Files+(Bitboards)

toc
 * Home * Board Representation * Bitboards * Pawn Pattern and Properties * Pawns and Files**

=File Types= Based on pawns, files are either **closed**, open or half-open. Rooks prefer open files for Mobility, to eventually enter the opponent side of the board. Rooks prefer own half-open files to attack opponent pawns if they are weak, such as backward or isolated.



Closed Files
Closed files have at least one white and one black pawn as member. They are the intersection of both white and black filefills. See semi-closed files. code format="cpp" U64 closedFiles(U64 wpanws, U64 bpawns) { return fileFill(wpanws) & fileFill(bpawns); } code

code white pawns        black pawns . . . . . . . .    . . . . . . . . . . . . . . . .     . 1 . . . 1 1 . . . . . . . . .     1 . 1 . . . . 1 . . . . . . . .     . . . 1 . . . . 1 . . . . 1 . .     . . . . . . . . . . 1 . . . . .     . . . . . . . . . 1 1 . . . 1 1     . . . . . . . . . . . . . . . .     . . . . . . . . white file fill  &  black file fill  =  closed files 1 1 1 . . 1 1 1    1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1  &  1 1 1 1 . 1 1 1  =  1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1     1 1 1 . . 1 1 1 code The complement set of closed files are either the open or halfopen files.



Open Files
Open files don't have any white or black pawn as member, thus it is the intersection of the filefills complements: code format="cpp" U64 openFiles(U64 wpanws, U64 bpawns) { return ~fileFill(wpanws) & ~fileFill(bpawns); } code

code white pawns        black pawns . . . . . . . .    . . . . . . . . . . . . . . . .     . 1 . . . 1 1 . . . . . . . . .     1 . 1 . . . . 1 . . . . . . . .     . . . 1 . . . . 1 . . . . 1 . .     . . . . . . . . . . 1 . . . . .     . . . . . . . . . 1 1 . . . 1 1     . . . . . . . . . . . . . . . .     . . . . . . . . ~white file fill  & ~black file fill =  open files . . . 1 1 . . .    . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .  &  . . . . 1 . . .  =  . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . .     . . . . 1 . . . code Alternative applying De Morgan, the complement of the unions: code format="cpp" U64 openFiles(U64 wpanws, U64 bpawns) { return ~(fileFill(wpanws) | fileFill(bpawns)); } code Or we may fill the union of both pawns, but it may be smarter to rely on common subexpression to allow inter-function optimizations of inlined functions: code format="cpp" U64 openFiles(U64 wpanws, U64 bpawns) { return ~fileFill(wpanws | bpawns); } code



Half-open Files
The complements of white or black filefills are either half-open (for either color) or open. code format="cpp" U64 halfOpenOrOpenFile(U64 gen) {return ~fileFill(gen);} code

code white pawns        black pawns . . . . . . . .    . . . . . . . . . . . . . . . .     . 1 . . . 1 1 . . . . . . . . .     1 . 1 . . . . 1 . . . . . . . .     . . . 1 . . . . 1 . . . . 1 . .     . . . . . . . . . . 1 . . . . .     . . . . . . . . . 1 1 . . . 1 1     . . . . . . . . . . . . . . . .     . . . . . . . . white file fill     black file fill 1 1 1 . . 1 1 1    1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 1 1 1 . . 1 1 1     1 1 1 1 . 1 1 1 white halfopen      black halfopen or open files      or open files . . . 1 1 . . .    . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . . . . 1 1 . . .     . . . . 1 . . . code Excluding open files by relative complement (xor), leaves the half-open files with at least one opponent pawn, but no own pawn. code format="cpp" U64 wHalfOpenFile(U64 wpawns, U64 bpanws) { return halfOpenOrOpenFile(wpawns) ^ openFiles(wpanws, bpawns); } code

code white halfopen                         white halfopen or open files   ^  open files       =  files . . . 1 1 . . .    . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .  ^  . . . . 1 . . .  =  . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . . . . 1 1 . . .     . . . . 1 . . .     . . . 1 . . . . code



Semi-closed Files
So far we considered following D-file closed, since both sides have one pawn on it. In fact due to captures the pawns are open, they are not member of any opponent frontspan. Thus, the file is more like eventually mutual half-open file. We need to filefill open pawns on closed files, to consider this subset.

code white pawns        black pawns . . . . . . . .    . . . . . . . . . . . . . . . .     . . . . . . . . . . . . . . . .     . . . . . . . . . . . 1 . . . .     . . . . . . . . . . . . . . . .     . . . 1 . . . . . . . . . . . .     . . . . . . . . . . . . . . . .     . . . . . . . . . . . . . . . .     . . . . . . . . code  =Filesets= As mentioned, the boolean information whether a file is occupied by a pawn or not, may be stored in one byte only - a fileset. South fill and casting to BYTE aka unsigned char is sufficient: code format="cpp" BYTE fileSet(U64 gen) {return (BYTE) soutFill(gen);} code Of course we can simply restore a filefill by zero-extending the fileset to a bitboard plus applying a north-fill multiplication with the A-file. code format="cpp" U64 filefill(BYTE fset) { U64 ff = fset; return ff * C64(0x0101010101010101); } code All the mentioned file-type sets may be handled this way. The advantage with one rank as set only - beside 1/8 space in pawnhash-table - there are no wraps to consider.

=What links here?= include page="Pawns and Files (Bitboards)" component="backlinks" limit="20"
 * Up one Level**