// 設定
const SETTEI = 1;
// ゲーム数
const GAME = 7000;
// 試行回数
const DAY = 10000;
/**
* 乱数テーブル
* ch_big: チェリービッグ
* ch_reg: チェリーレギュラー
* al_big: 単独ビッグ
* al_reg: 単独レギュラー
* replay: リプレイ
* grape: ぶどう
* al_cheery: チェリー(ボーナス非当選)
* miss: はずれ
*/
const RANDOM_TABLE = [
// 設定1
{
ch_big: { start: 1, end: 1091941 },
ch_reg: { start: 1091942, end: 1786724 },
al_big: { start: 1786725, end: 4356098 },
al_reg: { start: 4356099, end: 5934880 },
replay: { start: 5934881, end: 142958723 },
grape: { start: 142958724, end: 308961380 },
al_cheery: { start: 308961381, end: 339432721 },
miss: { start: 339432722, end: 1000000000 },
},
// 設定2
{
ch_big: { start: 1, end: 1086956 },
ch_reg: { start: 1086957, end: 1830949 },
al_big: { start: 1830950, end: 4452181 },
al_reg: { start: 4452182, end: 6210578 },
replay: { start: 6210579, end: 143234421 },
grape: { start: 143234422, end: 309237078 },
al_cheery: { start: 309237079, end: 339664194 },
miss: { start: 339664195, end: 1000000000 },
},
// 設定3
{
ch_big: { start: 1, end: 1086956 },
ch_reg: { start: 1086957, end: 1986966 },
al_big: { start: 1986967, end: 4608198 },
al_reg: { start: 4608199, end: 6729539 },
replay: { start: 6729540, end: 143753382 },
grape: { start: 143753383, end: 309756039 },
al_cheery: { start: 309756040, end: 339830632 },
miss: { start: 339830633, end: 1000000000 },
},
// 設定4
{
ch_big: { start: 1, end: 1158480 },
ch_reg: { start: 1158481, end: 2092100 },
al_big: { start: 2092101, end: 4794803 },
al_reg: { start: 4794804, end: 7035449 },
replay: { start: 7035450, end: 144059292 },
grape: { start: 144059293, end: 310061949 },
al_cheery: { start: 310061950, end: 339898330 },
miss: { start: 339898331, end: 1000000000 },
},
// 設定5
{
ch_big: { start: 1, end: 1158480 },
ch_reg: { start: 1158481, end: 2315754 },
al_big: { start: 2315755, end: 5018457 },
al_reg: { start: 5018458, end: 7783180 },
replay: { start: 7783181, end: 144807023 },
grape: { start: 144807024, end: 310809680 },
al_cheery: { start: 310809681, end: 340229884 },
miss: { start: 340229885, end: 1000000000 },
},
// 設定6
{
ch_big: { start: 1, end: 1157273 },
ch_reg: { start: 1157274, end: 2314547 },
al_big: { start: 2314548, end: 5079270 },
al_reg: { start: 5079271, end: 7843993 },
replay: { start: 7843994, end: 144867836 },
grape: { start: 144867837, end: 317878217 },
al_cheery: { start: 317878218, end: 347299627 },
miss: { start: 347299628, end: 1000000000 },
},
];
const OUTPUT_TABLE = {
ch_big: 251 + 2,
ch_reg: 95 + 2,
al_big: 251,
al_reg: 95,
replay: 3,
grape: 8,
al_cheery: 2,
miss: 0,
};
const KUJI = 1000000000;
const main = () => {
const result = {
samai: 0, // 差枚
inv: 0, // 投資額
bb: 0, // ビッグ合計
reg: 0, // レギュラー合計
win: 0, // 勝利数
};
[...Array(DAY)].forEach(() => {
const temp_result = {
coin: 0,
inv: 0,
bb: 0,
reg: 0,
};
[...Array(GAME)].forEach(() => {
if (temp_result.coin - 3 < 0) {
temp_result.inv += 50;
temp_result.coin += 50;
}
temp_result.coin += -3;
const ran = Math.floor(Math.random() * KUJI) + 1;
const role = Object.keys(RANDOM_TABLE[SETTEI - 1]).reduce((acc, key) => {
if (
ran >= RANDOM_TABLE[SETTEI - 1][key].start &&
ran <= RANDOM_TABLE[SETTEI - 1][key].end
) {
acc = key;
}
return acc;
}, '');
if (role === 'al_big' || role === 'ch_big') {
temp_result.bb++;
}
if (role === 'al_reg' || role === 'ch_reg') {
temp_result.reg++;
}
temp_result.coin += OUTPUT_TABLE[role];
});
const samai = temp_result.coin - temp_result.inv;
result.samai += samai;
result.inv += temp_result.inv;
result.bb += temp_result.bb;
result.reg += temp_result.reg;
samai >= 1 && result.win++;
});
const shaping = (value, base) => Math.round(value * base) / base;
// 出力
console.log('設定: ' + SETTEI);
console.log('勝率: ' + shaping((result.win / DAY) * 100, 100) + '%');
console.log('平均投資額: ' + shaping((result.inv / DAY) * 20, 1) + '円');
console.log(
'機械割: ' + shaping(100 + result.samai / (GAME * DAY) / 0.03, 100) + '%'
);
console.log('ビッグ確率: ' + shaping((GAME * DAY) / result.bb, 100));
console.log('レギュラー確率: ' + shaping((GAME * DAY) / result.reg, 100));
console.log('合算: ' + shaping((GAME * DAY) / (result.bb + result.reg), 100));
};
main();