## Counting endgame positions

Discussion of chess software programming and technical issues.

Moderators: bob, hgm, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Rein Halbersma
Posts: 685
Joined: Tue May 22, 2007 9:13 am

### Re: Counting endgame positions.

Ajedrecista wrote: Then your number is 1/8 of this second attempt. Same question again: what I am doing wrong?
Yes that is correct. The number 5.8e41 is the number of symmetry equivalent ways to put all the 32 initial pieces on the board, so no legality and pawns not on 1st or 8th row etc. It is indeed 1/8 of your factorial computation.

In the first version, you were doing a 4! incorrect. That would only apply if the 2 kings and queens were identical pieces. Instead, you need to do (1!)^4. This gives a factor of 24, and then another factor of 1/8 gives you my number.

Here's my Mathematica code, doing the calculation in 3 different ways. First as a specific coefficient in a cycle index polynomial, then as a Multinomial function, and finally as a bunch of factorials.

Code: Select all

``````In&#91;56&#93;&#58;= Z&#91;x1_,x2_,x4_&#93;&#58;=&#40;1*x1^64+2*x1^8 x2^28 + 3*x2^32+2*x4^16&#41;/8
In&#91;57&#93;&#58;= ChessZ =Z&#91;&#40;P0+P1+P2+P3+P4+P5+P6+P7+P8+ P9 +P10 +P11 + P12 ),&#40;P0^2+P1^2+P2^2+P3^2+P4^2+P5^2+P6^2+P7^2+P8^2+P9^2+P10^2+P11^2+P12^2&#41;,&#40;P0^4+P1^4+P2^4+P3^4+P4^4+P5^4+P6^4+P7^4+P8^4+P9^4+P10^4+P11^4+P12^4&#41;&#93;
Out&#91;57&#93;= 1/8 (&#40;P0+P1+P10+P11+P12+P2+P3+P4+P5+P6+P7+P8+P9&#41;^64+2 &#40;P0+P1+P10+P11+P12+P2+P3+P4+P5+P6+P7+P8+P9&#41;^8 &#40;P0^2+P1^2+P10^2+P11^2+P12^2+P2^2+P3^2+P4^2+P5^2+P6^2+P7^2+P8^2+P9^2&#41;^28+3 &#40;P0^2+P1^2+P10^2+P11^2+P12^2+P2^2+P3^2+P4^2+P5^2+P6^2+P7^2+P8^2+P9^2&#41;^32+2 &#40;P0^4+P1^4+P10^4+P11^4+P12^4+P2^4+P3^4+P4^4+P5^4+P6^4+P7^4+P8^4+P9^4&#41;^16&#41;
In&#91;58&#93;&#58;= Coefficient&#91;ChessZ,P0^62P1 P2 &#93;
Coefficient&#91;ChessZ,P0^58 P1 P2 P3^2 P4^2 &#93;
Coefficient&#91;ChessZ,P0^32 P1 P2 P3 P4 P5^2 P6^2 P7^2 P8^2 P9^2 P10^2 P11^8 P12^8 &#93;
Out&#91;58&#93;= 518
Out&#91;59&#93;= 1686946884
Out&#91;60&#93;= 579340836948476205149027870013146842320000
In&#91;67&#93;&#58;= Multinomial&#91;32,8,8,2,2,2,2,2,2,1,1,1,1&#93;/8
Out&#91;67&#93;= 579340836948476205149005747790410708800000
In&#91;66&#93;&#58;= &#40;64!/&#40;32! &#40;8!)^2  &#40;2!)^6&#41;)/8
Out&#91;66&#93;= 579340836948476205149005747790410708800000``````
The reason the cycle polynomial works is because of the multinomial theorem. Doing a small endgame by hand, you will see that the expansion will give you exactly the same factorials as if you would do the calculation from scratch.

Ajedrecista
Posts: 1400
Joined: Wed Jul 13, 2011 7:04 pm
Contact:

### Re: Counting endgame positions.

Hello again:
Rein Halbersma wrote:In the first version, you were doing a 4! incorrect. That would only apply if the 2 kings and queens were identical pieces. Instead, you need to do (1!)^4. This gives a factor of 24, and then another factor of 1/8 gives you my number.
That's true! I was more convinced on my second attempt, but I went crazy in my first calculation for some unknown reason. In fact, you can see (1!)*(1!)*(1!)*(1!) in my second try.

Thanks for pointing out my mistake! I even explained myself well in my second calculation, so I definitively went crazy... it is Friday! 