Created
January 15, 2021 13:05
-
-
Save geektheripper/e165a3c5b4bd779da5cd782586c92b0c 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
var blessed = require("blessed"), | |
contrib = require("blessed-contrib"), | |
screen = blessed.screen({ fullUnicode: true }); | |
function chouka(charReq, stuffReq) { | |
let char = new Set(); | |
let stuff = new Set(); | |
let count = 0; | |
const isEnd = () => | |
(charReq - char.size) * 100 + (stuffReq - stuff.size) * 50 <= count; | |
while (!isEnd()) { | |
count++; | |
const rand = Math.random(); | |
if (rand < 0.59 * 0.05) { | |
char.add(Math.ceil(Math.random() * 4)); | |
} else if (Math.random() < 0.49 * 0.15 + 0.59 * 0.05) { | |
stuff.add(Math.ceil(Math.random() * 5)); | |
} | |
} | |
return count; | |
} | |
let emulTimes = 1000000; | |
let totlalCount = 0; | |
let countDensity = {}; | |
for (let i = 0; i < emulTimes; i++) { | |
const count = chouka(4, 5); | |
totlalCount += count; | |
const rangeEnd = Math.ceil(count / 10); | |
countDensity[rangeEnd] = countDensity[rangeEnd] || 0; | |
countDensity[rangeEnd]++; | |
} | |
const avgDraw = Math.ceil((totlalCount / emulTimes) * 100) / 100; | |
const avg10Draw = Math.ceil((avgDraw / 10) * 100) / 100; | |
const avgCost = Math.ceil((avgDraw / 36) * 648); | |
var bar = contrib.bar({ | |
label: [ | |
`模拟100w次氪到联动角色和物品全出为止,十连次数的分布图`, | |
`平均需要${avgDraw}抽,${avg10Draw}次十连,${avgCost}RMB(不考虑首充)`, | |
`[648一单/计算了天井]`, | |
].join("\n"), | |
barWidth: 2, | |
barSpacing: 2, | |
height: "60%", | |
xOffset: 0, | |
maxHeight: Math.max(...Object.values(countDensity)) / 0.9, | |
}); | |
screen.append(bar); | |
bar.setData({ | |
titles: Object.keys(countDensity), | |
data: Object.values(countDensity), | |
}); | |
screen.render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment