Last active
March 30, 2023 07:54
-
-
Save tomohxx/5228d7de3fc1fbee93aa3ba104f80928 to your computer and use it in GitHub Desktop.
国士無双の聴牌確率(巡目別牌種数別)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <iomanip> | |
#include <iostream> | |
int main() | |
{ | |
constexpr int T_MAX = 18; | |
constexpr int T_MIN = 1; | |
constexpr int S = 123; // 四麻 | |
// constexpr int S = 95; // 三麻 | |
std::array<std::array<std::array<double, T_MAX + 1>, 2>, 14> table = {}; | |
for (int t = T_MIN; t <= T_MAX; ++t) { | |
table[13][0][t] = 1.; | |
table[12][1][t] = 1.; | |
} | |
for (int i = 12; i >= 0; --i) { | |
if (i < 12) { | |
for (int t = T_MAX - 1; t >= T_MIN; --t) { | |
table[i][1][t] = (1. - 4. * (13 - i) / (S - t)) * table[i][1][t + 1] + | |
4. * (13 - i) / (S - t) * table[i + 1][1][t + 1]; | |
} | |
} | |
for (int t = T_MAX - 1; t >= T_MIN; --t) { | |
table[i][0][t] = (1. - (52. - i) / (S - t)) * table[i][0][t + 1] + | |
4 * (13. - i) / (S - t) * table[i + 1][0][t + 1] + | |
3. * i / (S - t) * table[i][1][t + 1]; | |
} | |
} | |
std::cout << std::setw(5) << std::left << "Turn"; | |
for (int i = 12; i >= 0; --i) { | |
std::cout << std::setw(12) << std::left << i; | |
} | |
std::cout << "\n"; | |
for (int j = 0; j <= 1; ++j) { | |
std::cout << "\n"; | |
for (int t = T_MIN; t <= T_MAX; ++t) { | |
std::cout << std::setw(5) << t; | |
for (int i = 12; i >= 0; --i) { | |
std::cout << std::setw(12) << std::setprecision(4) | |
<< std::scientific << table[i][j][t]; | |
} | |
std::cout << "\n"; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment