Search code examples
chess

Dumb7Fill queen and rook attacks seem to jump over "ours" pieces


I am trying to play with chess programming and currently program BitBoards. All is fine except for Dumb7Fill (unrolled loops) generating attacks that allow queen and rook jump over their pieces. Bellow are traces of execution. What am I doing wrong here? The code for *Attack is taken straight from the wiki page, which means that moves are extended into attacks by north, south, west and east shift. This is programmed in Java.

    long rooks = (One << index);
    long empty = ~rep.getOccupancy();
    long attacks = southAttack(rooks, empty)
            | northAttack(rooks, empty)
            | eastAttack(rooks, empty)
            | westAttack(rooks, empty);
    long actual = (attacks & rep.getCurrentPosition(getColor().inverse()));

ROOK ATTACKS w
rooks w 

. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
1 . . . . . . . 
n: 1

empty w 
. . . . . . . . 
1 . . . . . . . 
1 1 1 1 1 1 1 1 
. 1 1 1 1 1 1 1 
. 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
1 . . . . . . . 
. . . . . . . . 
n: 1fffefeff0100

theirs w 
1 1 1 1 1 1 1 1 
. 1 1 1 1 1 1 1 
. . . . . . . . 
p . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
n: fffe000100000000

ours w 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
P . . . . . . . 
. . . . . . . . 
. 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 1 
n: 100feff

attacks from Dumb7Fill w 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
1 . . . . . . . 
1 . . . . . . . 
1 . . . . . . . 
. . . . . . . . 
. . 1 . . . . . 
n: 101010004

actual attack w 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
1 . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
. . . . . . . . 
n: 100000000

Solution

  • It turns out I misinterpreted the algorithms on the wiki page. The attacks include the shift by one and are attacks and not moves, as I have interpreted them. For moves one needs to use occluded fills.