コイン | 都市-都市 | 大農園-都市 | 都市-魔法のランプ | 独立都市-漁村 | 独立都市-農村 | 独立都市-幸運の銀貨 | 独立都市-農村x2 | 独立都市-春風の妖精 | 独立都市-家守の精霊 |
---|---|---|---|---|---|---|---|---|---|
2 | 2.65% | 1.51% | 2.66% | 4.55% | 3.54% | 4.55% | 2.80% | 2.18% | 2.65% |
3 | 15.02% | 12.33% | 14.16% | 22.72% | 21.23% | 22.72% | 19.57% | 15.96% | 14.15% |
4 | 29.28% | 25.80% | 22.09% | 22.75% | 26.50% | 22.74% | 29.36% | 26.81% | 21.23% |
5 | 31.83% | 24.92% | 23.98% | 6.07% | 8.09% | 5.68% | 10.49% | 10.82% | 21.21% |
6 | 16.80% | 19.98% | 20.33% | 13.61% | 10.60% | 11.75% | 8.38% | 7.69% | 8.08% |
7 | 4.42% | 11.47% | 12.35% | 22.73% | 21.20% | 23.09% | 19.61% | 24.50% | 15.89% |
8 | --.--% | 4.00% | 4.43% | 7.58% | 8.85% | 9.46% | 9.80% | 12.04% | 16.80% |
6+ | 21.22% | 35.45% | 37.12% | 43.92% | 40.65% | 44.31% | 37.79% | 44.23% | 40.77% |
Last active
August 29, 2015 14:02
-
-
Save kana/0748e75a5c9a60135235 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
def deck_from_spec(spec) | |
deck = [] | |
spec.each do |name, count| | |
count.times do | |
deck << name | |
end | |
end | |
deck | |
end | |
def coin(name, has_damaid) | |
case name | |
when :farm | |
1 | |
when :city | |
2 | |
when :damaid | |
0 | |
when :independent_city | |
4 | |
when :yamori | |
1 + (has_damaid ? 1 : 0) | |
when :silver | |
1 | |
when :lamp | |
3 | |
when :big_farm | |
3 | |
when :fairy | |
0 | |
end | |
end | |
class Array | |
def discard(name) | |
delete_at(find_index(name)) | |
end | |
end | |
module Enumerable | |
def sum() | |
inject(:+) | |
end | |
end | |
def calc(n, spec) | |
deck = deck_from_spec(spec) | |
result = {} | |
n.times do | |
library = deck.shuffle | |
hand = library.shift(5) | |
has_damaid = hand.include?(:damaid) | |
has_silver = hand.include?(:silver) | |
has_independent_city = hand.include?(:independent_city) | |
has_fairy = hand.include?(:fairy) | |
if has_silver and not has_independent_city | |
hand.discard(:silver) | |
hand << library.shift | |
end | |
if has_fairy and has_damaid | |
hand.discard(:fairy) | |
hand.discard(:damaid) | |
hand << library.shift | |
hand << library.shift | |
end | |
if has_fairy and not has_damaid and not has_independent_city | |
hand.discard(:fairy) | |
hand.discard(:farm) | |
hand << library.shift | |
hand << library.shift | |
end | |
gain = hand.map {|name| coin(name, has_damaid)}.sum() | |
result[gain] ||= 0 | |
result[gain] += 1 | |
end | |
result | |
end | |
def pp_one(coin, prob, max_count_width, count, total_count) | |
puts "Coin %2s: %5.2f%% (%*d/%d)\n" % [coin, prob * 100, max_count_width, count, total_count] | |
end | |
def pp(stat_table) | |
total_count = stat_table.values.sum() | |
max_count_width = stat_table.values.map {|coin| coin.to_s.length}.max() | |
stat_table.keys.sort.each do |coin| | |
count = stat_table[coin] | |
prob = count / total_count.to_f | |
pp_one(coin, prob, max_count_width, count, total_count) | |
end | |
count = stat_table.keys.find_all {|coin| 6 <= coin}.map {|coin| stat_table[coin]}.sum() | |
prob = count / total_count.to_f | |
pp_one('6+', prob, max_count_width, count, total_count) | |
end | |
n = 10000000 # 30 sec | |
# n = 1000000 # 3 sec | |
# n = 100 | |
# pp calc(n, {farm: 7, damaid: 3, city: 2}) | |
# 都市-都市スタート | |
# Coin 2: 2.65% ( 264816/10000000) | |
# Coin 3: 15.02% (1501911/10000000) | |
# Coin 4: 29.28% (2927977/10000000) | |
# Coin 5: 31.83% (3183430/10000000) | |
# Coin 6: 16.80% (1679797/10000000) | |
# Coin 7: 4.42% ( 442069/10000000) | |
# Coin 6+: 21.22% (2121866/10000000) | |
# pp calc(n, {farm: 7, damaid: 3, city: 1, lamp: 1}) | |
# 都市-魔法のランプor金貸しスタート | |
# Coin 2: 2.66% ( 265733/10000000) | |
# Coin 3: 14.16% (1415905/10000000) | |
# Coin 4: 22.09% (2208671/10000000) | |
# Coin 5: 23.98% (2398154/10000000) | |
# Coin 6: 20.33% (2033182/10000000) | |
# Coin 7: 12.35% (1235023/10000000) | |
# Coin 8: 4.43% ( 443332/10000000) | |
# Coin 6+: 37.12% (3711537/10000000) | |
# pp calc(n, {farm: 7, damaid: 3, independent_city: 1}) | |
# 独立都市-漁村or早馬or伝令or敢えて何も買わないスタート(擁立選択時) | |
# Coin 2: 4.55% ( 454658/10000000) | |
# Coin 3: 22.72% (2271896/10000000) | |
# Coin 4: 22.75% (2275113/10000000) | |
# Coin 5: 6.07% ( 606731/10000000) | |
# Coin 6: 13.61% (1361404/10000000) | |
# Coin 7: 22.73% (2272685/10000000) | |
# Coin 8: 7.58% ( 757513/10000000) | |
# Coin 6+: 43.92% (4391602/10000000) | |
# pp calc(n, {farm: 7 + 1, damaid: 3, independent_city: 1}) | |
# 独立都市-農村or何か1コイン出るカードスタート(擁立選択時) | |
# Coin 2: 3.54% ( 354306/10000000) | |
# Coin 3: 21.23% (2122757/10000000) | |
# Coin 4: 26.50% (2649665/10000000) | |
# Coin 5: 8.09% ( 808537/10000000) | |
# Coin 6: 10.60% (1059765/10000000) | |
# Coin 7: 21.20% (2120126/10000000) | |
# Coin 8: 8.85% ( 884844/10000000) | |
# Coin 6+: 40.65% (4064735/10000000) | |
# pp calc(n, {farm: 7 + 2, damaid: 3, independent_city: 1}) | |
# 独立都市-農村&農村スタート(擁立選択時) | |
# Coin 2: 2.80% ( 279869/10000000) | |
# Coin 3: 19.57% (1957404/10000000) | |
# Coin 4: 29.36% (2935568/10000000) | |
# Coin 5: 10.49% (1048618/10000000) | |
# Coin 6: 8.38% ( 837842/10000000) | |
# Coin 7: 19.61% (1960922/10000000) | |
# Coin 8: 9.80% ( 979777/10000000) | |
# Coin 6+: 37.79% (3778541/10000000) | |
# pp calc(n, {farm: 7, damaid: 3, independent_city: 1, yamori: 1}) | |
# 独立都市-家守の精霊スタート(擁立選択時) | |
# Coin 2: 2.65% ( 264561/10000000) | |
# Coin 3: 14.15% (1414739/10000000) | |
# Coin 4: 21.23% (2123125/10000000) | |
# Coin 5: 21.21% (2121028/10000000) | |
# Coin 6: 8.08% ( 807975/10000000) | |
# Coin 7: 15.89% (1588856/10000000) | |
# Coin 8: 16.80% (1679716/10000000) | |
# Coin 6+: 40.77% (4076547/10000000) | |
# pp calc(n, {farm: 7, damaid: 3, independent_city: 1, silver: 1}) | |
# 独立都市-幸運の銀貨スタート(手札に独立都市が無いなら幸運の銀貨でドローを選択)(擁立選択時) | |
# Coin 2: 4.55% ( 455285/10000000) | |
# Coin 3: 22.72% (2272362/10000000) | |
# Coin 4: 22.74% (2273710/10000000) | |
# Coin 5: 5.68% ( 567933/10000000) | |
# Coin 6: 11.75% (1174891/10000000) | |
# Coin 7: 23.09% (2309399/10000000) | |
# Coin 8: 9.46% ( 946420/10000000) | |
# Coin 6+: 44.31% (4430710/10000000) | |
# pp calc(n, {farm: 7 + 1, damaid: 3, independent_city: 1, fairy: 1}) | |
# 独立都市-春風の妖精スタート(擁立選択時) | |
# * 手札に見習い侍女があれば交換する(286,8489/1000,0000) | |
# * 手札に独立都市も見習い侍女もなければ農村を交換する(54,3776/1000,0000) | |
# Coin 2: 2.18% ( 217837/10000000) | |
# Coin 3: 15.96% (1595718/10000000) | |
# Coin 4: 26.81% (2681089/10000000) | |
# Coin 5: 10.82% (1082193/10000000) | |
# Coin 6: 7.69% ( 768664/10000000) | |
# Coin 7: 24.50% (2450261/10000000) | |
# Coin 8: 12.04% (1204238/10000000) | |
# Coin 6+: 44.23% (4423163/10000000) | |
# pp calc(n, {farm: 7 + 3, damaid: 3, big_farm: 1, city: 1}) | |
# 大農園-都市スタート | |
# Coin 2: 1.51% ( 150517/10000000) | |
# Coin 3: 12.33% (1232560/10000000) | |
# Coin 4: 25.80% (2579769/10000000) | |
# Coin 5: 24.92% (2492287/10000000) | |
# Coin 6: 19.98% (1997731/10000000) | |
# Coin 7: 11.47% (1146769/10000000) | |
# Coin 8: 4.00% ( 400367/10000000) | |
# Coin 6+: 35.45% (3544867/10000000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment