Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- class String
- def for_2ch
- self.gsub(/ {2,}/) do |spaces|
- len = spaces.length
- if len.even?
- " " * (len / 2)
- else
- (" " * (len / 2)) + " "
- end
- end
- end
- end
- # config me
- sr_per = 3.00r
- hr_per = 17.80r
- set_price = 5800r
- set_stars = 6600r
- yen_per_star = set_price / set_stars
- header = <<-EOT
- 10000人がガチャ引いたときの回数毎のSR・HRハズレ人数
- SR確率#{sr_per.to_f.round(2)}%、HR確率#{hr_per.to_f.round(2)}%、星くず1個#{yen_per_star.to_f.round(2)}円(#{set_price.to_i}円/#{set_stars.to_i}個)で計算
- * 連(回数 金額): SR率(ハズレ) HR率(ハズレ)
- EOT
- puts header.for_2ch
- sr_win_probability = sr_per / 100
- sr_lose_probability = 1 - sr_win_probability
- hr_win_probability = hr_per / 100
- hr_lose_probability = 1 - hr_win_probability
- (1..30).each do |i|
- times = i * 11
- sr_win = (1 - (sr_lose_probability ** times))
- sr_lose = 1 - sr_win
- hr_win = (1 - (hr_lose_probability ** times))
- hr_lose = 1 - hr_win
- cost = 4000 * yen_per_star * i
- str = "* %3d連(x%2d %6d円): %3d%%(%4d人) %3d%%(%4d人)" % [
- times,
- i,
- cost.to_f.round,
- (sr_win * 100).to_f.round,
- (sr_lose * 10000).to_f.round,
- (hr_win * 100).to_f.round,
- (hr_lose * 10000).to_f.round,
- ]
- puts str.for_2ch
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement