1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 16:53:09 +00:00

Simplify Pawnidx[] init code

But still not clear what we have here...
This commit is contained in:
Marco Costalba 2016-05-15 14:17:44 +02:00
parent e435f85b02
commit 7448fce808

View file

@ -1584,26 +1584,27 @@ void Tablebases::init(const std::string& paths)
MapToEdges[s] = 48 - f - 2 * rank_of(s); MapToEdges[s] = 48 - f - 2 * rank_of(s);
} }
// Fill Binomial[] with the Binomial Coefficents using Pascal triangle // Fill Binomial[] with the Binomial Coefficents using Pascal rule. There
// are Binomial[k][n] ways to choose k elements from a set of n elements.
Binomial[0][0] = 1; Binomial[0][0] = 1;
for (int n = 1; n < 64; n++) for (int n = 1; n < 64; n++) // Squares
for (int k = 0; k < 6 && k <= n; ++k) for (int k = 0; k < 6 && k <= n; ++k) // Pieces
Binomial[k][n] = (k > 0 ? Binomial[k-1][n-1] : 0) Binomial[k][n] = (k > 0 ? Binomial[k - 1][n - 1] : 0)
+ (k < n ? Binomial[k][n-1] : 0); + (k < n ? Binomial[k ][n - 1] : 0);
for (int i = 0; i < 5; ++i) { for (int k = 0; k < 5; ++k) {
int k = 0; int n = 0;
for (int j = 1; j <= 4; ++j) { for (int f = 1; f <= 4; ++f) {
int s = 0; int s = 0;
for ( ; k < 6 * j; ++k) { for ( ; n < 6 * f; ++n) {
Pawnidx[i][k] = s; Pawnidx[k][n] = s;
s += Binomial[i][MapToEdges[8 * (k % 6) + k / 6 + 8]]; s += Binomial[k][47 - 2 * n];
} }
Pfactor[i][j - 1] = s; Pfactor[k][f - 1] = s;
} }
} }