Changes

Jump to: navigation, search

Pawns and Files (Bitboards)

7,066 bytes added, 11:10, 10 May 2018
Created page with "'''Home * Board Representation * Bitboards * Pawn Pattern and Properties * Pawns and Files''' Based on pawns, files are either ''..."
'''[[Main Page|Home]] * [[Board Representation]] * [[Bitboards]] * [[Pawn Pattern and Properties]] * Pawns and Files'''

Based on [[Pawn|pawns]], [[Files|files]] are either '''closed''', [[Open file|open]] or [[Half-open file|half-open]]. [[Rook|Rooks]] prefer open files for [[Mobility]], to eventually enter the opponent side of the board. Rooks further prefer own half-open files to attack opponent pawns if they are weak, such as [[Backward Pawn|backward]] or [[Isolated Pawn|isolated]].

<span id="ClosedFiles"></span>
=Closed Files=
Closed files have at least one white and one black pawn as member. They are the intersection of both white and black [[Pawn Fills#FileFill|filefills]]. See [[Open Pawns (Bitboards)#SemiClosedFiles|semi-closed files]].
<pre>
U64 closedFiles(U64 wpanws, U64 bpawns) {
return fileFill(wpanws) & fileFill(bpawns);
}
</pre>

<pre>
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
</pre>
The complement set of closed files are either the open or halfopen files.
<span id="OpenFiles"></span>
=Open Files=
[[Open file|Open files]] don't have any white or black pawn as member, thus it is the intersection of the [[Pawn Fills#FileFill|filefills]] complements:
<pre>
U64 openFiles(U64 wpanws, U64 bpawns) {
return ~fileFill(wpanws) & ~fileFill(bpawns);
}
</pre>

<pre>
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 . . .
</pre>
Alternative applying [[General Setwise Operations#DeMorganslaws|De Morgan]] , the complement of the unions:
<pre>
U64 openFiles(U64 wpanws, U64 bpawns) {
return ~(fileFill(wpanws) | fileFill(bpawns));
}
</pre>
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:
<pre>
U64 openFiles(U64 wpanws, U64 bpawns) {
return ~fileFill(wpanws | bpawns);
}
</pre>
<span id="HalfopenFiles"></span>
=Half-open Files=
The complements of white or black [[Pawn Fills#FileFill|filefills]] are either [[Half-open file|half-open]] (for either color) or [[Open file|open]].
<pre>
U64 halfOpenOrOpenFile(U64 gen) {return ~fileFill(gen);}
</pre>

<pre>
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 . . .
</pre>
Excluding open files by relative complement (xor), leaves the half-open files with at least one opponent pawn, but no own pawn.
<pre>
U64 wHalfOpenFile(U64 wpawns, U64 bpanws) {
return halfOpenOrOpenFile(wpawns)
^ openFiles(wpanws, bpawns);
}
</pre>

<pre>
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 . . . .
</pre>
<span id="SemiClosedFiles"></span>
=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 Pawns (Bitboards)|open]], they are not member of any opponent frontspan. Thus, the file is more like eventually mutual half-open file. We need to [[Pawn Fills#FileFill|filefill]] [[Open Pawns (Bitboards)|open pawns]] on closed files, to consider this subset.
<pre>
white pawns black pawns
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . 1 . . . . . . . . . . . .
. . . . . . . . . . . 1 . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
</pre>
<span id="Fileset"></span>
=Filesets=
As mentioned, the boolean information whether a file is occupied by a pawn or not, may be stored in one [[Byte|byte]] only - a fileset. South fill and casting to BYTE aka unsigned char is sufficient:
<pre>
BYTE fileSet(U64 gen) {return (BYTE) soutFill(gen);}
</pre>
Of course we can simply restore a filefill by zero-extending the fileset to a bitboard plus applying a [[General Setwise Operations#Multiplication|north-fill multiplication]] with the A-file.
<pre>
U64 filefill(BYTE fset) {
U64 ff = fset;
return ff * C64(0x0101010101010101);
}
</pre>
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.

'''[[Pawn Pattern and Properties|Up one Level]]'''

Navigation menu