Kogge-Stone example in Chess Programming Wiki

Discussion of chess software programming and technical issues.

Moderator: Ras

Joker
Posts: 2
Joined: Sat Mar 01, 2025 9:47 pm
Full name: Marco Brenco

Kogge-Stone example in Chess Programming Wiki

Post by Joker »

Being new to chess engines I tried to understand how Kogge-Stone works, so I created a step-by-step example very close to "some south fill cycles in slow motion" as described for dumb7fill in https://www.chessprogramming.org/Dumb7Fill
I think it could be worth adding it to https://www.chessprogramming.org/Kogge-Stone_Algorithm as well, to make it clearer what happens.
If some contributor to Chess Programming Wiki agrees on that I could post the example here so that it can be added to that page.
Thanks
smatovic
Posts: 3218
Joined: Wed Mar 10, 2010 10:18 pm
Location: Hamburg, Germany
Full name: Srdja Matovic

Re: Kogge-Stone example in Chess Programming Wiki

Post by smatovic »

Feel free to post your implementation in here and I will add a link to CPW article in the Forum Post section. Consider the "code" tags for nice formatting.

--
Srdja
Joker
Posts: 2
Joined: Sat Mar 01, 2025 9:47 pm
Full name: Marco Brenco

Re: Kogge-Stone example in Chess Programming Wiki

Post by Joker »

Thanks Srdja
here it is.

Code: Select all

gen =
brooks|bqueen        pro
1 . . . . . . .      . 1 1 1 1 1 . 1
. . . 1 . . . .      1 1 . . 1 . 1 .
. . . . . . . .      1 . 1 1 1 1 . 1
. . . . . . . .      1 1 . 1 1 1 1 1
. . . . . 1 . .      1 1 1 . 1 . 1 1
. . . . . . . .      1 1 . 1 1 1 1 .
. . . . . . . .      . . . 1 1 . . 1
. . . . . . . .      . 1 1 . 1 1 . 1
1. gen |= pro & (gen >>  8);
  gen >> 8           & pro               | gen   => gen
. . . . . . . .      . . . . . . . .     1 . . . . . . .
1 . . . . . . .      1 . . . . . . .     1 . . 1 . . . .
. . . 1 . . . .      . . . 1 . . . .     . . . 1 . . . .
. . . . . . . .      . . . . . . . .     . . . . . . . .
. . . . . . . .      . . . . . . . .     . . . . . 1 . .
. . . . . 1 . .      . . . . . 1 . .     . . . . . 1 . .
. . . . . . . .      . . . . . . . .     . . . . . . . .
. . . . . . . .      . . . . . . . .     . . . . . . . .
2. pro &=       (pro >>  8);
  pro >> 8           & pro   => pro
. . . . . . . .      . . . . . . . .
. 1 1 1 1 1 . 1      . 1 . . 1 . . .
1 1 . . 1 . 1 .      1 . . . 1 . . .
1 . 1 1 1 1 . 1      1 . . 1 1 1 . 1
1 1 . 1 1 1 1 1      1 1 . . 1 . 1 1
1 1 1 . 1 . 1 1      1 1 . . 1 . 1 .
1 1 . 1 1 1 1 .      . . . 1 1 . . .
. . . 1 1 . . 1      . . . . 1 . . 1
3. gen |= pro & (gen >>  16);
  gen >> 16          & pro               | gen   => gen
. . . . . . . .      . . . . . . . .     1 . . . . . . .
. . . . . . . .      . . . . . . . .     1 . . 1 . . . .
1 . . . . . . .      1 . . . . . . .     1 . . 1 . . . .
1 . . 1 . . . .      1 . . 1 . . . .     1 . . 1 . . . .
. . . 1 . . . .      . . . . . . . .     . . . . . 1 . .
. . . . . . . .      . . . . . . . .     . . . . . 1 . .
. . . . . 1 . .      . . . . . . . .     . . . . . . . .
. . . . . 1 . .      . . . . . . . .     . . . . . . . .
4. pro &=       (pro >>  16);
  pro >> 16           & pro   => pro
. . . . . . . .      . . . . . . . .
. . . . . . . .      . . . . . . . .
. . . . . . . .      . . . . . . . .
. 1 . . 1 . . .      . . . . 1 . . .
1 . . . 1 . . .      1 . . . 1 . . .
1 . . 1 1 1 . 1      1 . . . 1 . . .
1 1 . . 1 . 1 1      . . . . 1 . . .
1 1 . . 1 . 1 .      . . . . 1 . . .
5. gen |= pro & (gen >>  32);
  gen >> 32          & pro               | gen   => gen
. . . . . . . .      . . . . . . . .     1 . . . . . . .
. . . . . . . .      . . . . . . . .     1 . . 1 . . . .
. . . . . . . .      . . . . . . . .     1 . . 1 . . . .
. . . . . . . .      . . . . . . . .     1 . . 1 . . . .
1 . . . . . . .      1 . . . . . . .     1 . . . . 1 . .
1 . . 1 . . . .      1 . . . . . . .     1 . . . . 1 . .
1 . . 1 . . . .      . . . . . . . .     . . . . . . . .
1 . . 1 . . . .      . . . . . . . .     . . . . . . . .