Computer Chess Club Archives


Search

Terms

Messages

Subject: Natural move generation with bitboards

Author: Gerd Isenberg

Date: 15:17:36 09/20/04

Go up one level in this thread


Looking back to Steffan Westcott's great posts about
"Natural move generation with bitboards"

http://chessprogramming.org/cccsearch/ccc.php?art_id=266455
http://chessprogramming.org/cccsearch/ccc.php?art_id=266676

with the idea to generate disjoint direction-wise attacks for each piece type
inside a fixed sized structure.

For white/black pawn bitboards we need only two attack directions by simply
shifting all pawns per side by 7 or 9 in the appropriate direction, considering
board wraps performing the usual notA- or notH-masks before or after shifting.
Both target bitboards may be "anded" to get double pawn attacks or may be "ored"
to get pawn-attacks independent of the direction.

If we traverse pawn targets direction-wise, anded by opposite pieces to generate
pawn captures, the source square of a target is simply determined by shifting in
the opposite attack direction. Or in move-square metrics instead of bitboard
metrics one may add/sub 7 or 9.

Steffan suggested to do similar technique with sliders using Kogge-Stone fills
for each sliding piece type too. With the advantage to generate multiple pieces
per direction once, for all straight or diagonal sliders, possibly combining
queen and rooks or queen and bishops. Even if there is a unique relation between
one target and source square per direction, it is, compared to pawns captures,
not that easy to map the target to the source square for sliders. Indeed, as
Steffan mentioned, a fill in the opposite direction with a single isolated
target square is required to determine the unique source square by "and".

Specially for ALL-nodes a lot of additional fill stuff to do, which IMHO is
worth to avoid by better keeping disjoint piece attacks for sliders as well.
Piece-wise attacks is IMHO also important for eval, looking for trapped or
immobile pieces.

One possible compromize for sliding pieces is the quad-bitboard Kogge-Stone, i
mentioned recently, introducing two unique piece codes for rooks. At least for
usual sliding pieces per side (<= 2rooks, <= 1bishop per square color and <= 1
queen), the routine generates direction-wise attacks piece wise. The routines
fills a quad-bitboard with 4-bit piece code along all eight sliding directions.
En passant all pieces are filled queen wise, beside the sliders of both sides
also both kings as meta-queen.

Yes, Knights don't really fit so well in the above design of a fixed sized
attack structure, with disjoint direction and piece type as well as usually each
sliding piece. Since we most often have only up to two knights per side but not
ten, it seems a waste of space to compute knights similar to pawns but for all
eight knight directions (1 o'clock, 2 o'clock, 4 o'clock, etc).

Anyway, i like the quad-bitboard idea here too, to generete all eight knight
direction attacks with all pieces simultaniously. To get up to two disjoint
knight attack sets per side, the quad-bitboard contains two different knight
piece codes for first knight and remaining knights per side here, instead of two
different rook codes for sliding attacks.

Simultaniously processing king, queen and rooks and bishops knightattack-wise is
nice to find knight check targets as well as attacks to heavy pieces or hanging
bishops and of course all kinds of forks.

Gerd



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.