基本上,我有一个我正在制作的网站,它是通用回形针的衍生产品,它被称为橡皮筋。当然,在此过程中,您需要找到一个合适的公式来计算公共利益的增长与购买橡皮筋的人数的关系。因此,公众利益越高,购买您的橡皮筋的人就越多。
我有一个我正在使用的公式,但它非常主观且有缺陷,而且如果您的公共利益超过 800%,它就不起作用。以下是我以 100 毫秒间隔使用的公式。
setInterval (function() {
if (publicinterest < 100) {
if (Math.random() < publicinterest / 200) {
if (Math.random() < publicinterest / 200) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider /
sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML =
'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML =
'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML =
"Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 200) {
if (Math.random() * 2 < publicinterest / 190) {
if (Math.random() * 2 < publicinterest / 190) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 300) {
if (Math.random() * 3 < publicinterest / 180) {
if (Math.random() * 3 < publicinterest / 180) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 400) {
if (Math.random() * 4 < publicinterest / 170) {
if (Math.random() * 4 < publicinterest / 170) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 500) {
if (Math.random() * 5 < publicinterest / 160) {
if (Math.random() * 5 < publicinterest / 160) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 600) {
if (Math.random() * 6 < publicinterest / 150) {
if (Math.random() * 6 < publicinterest / 150) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 700) {
if (Math.random() * 7 < publicinterest / 140) {
if (Math.random() * 7 < publicinterest / 140) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
if (publicinterest < 800) {
if (Math.random() * 8 < publicinterest / 130) {
if (Math.random() * 8 < publicinterest / 130) {
if (unsoldrubberbands > 0) {
money += sellingprice;
publicinterest = publicinterestdecider / sellingprice;
unsoldrubberbands -= 1;
document.getElementById('moneytext').innerHTML = 'Money: $' + money.toFixed(2);
document.getElementById('inventory').innerHTML = 'Inventory: ' + unsoldrubberbands;
document.getElementById('publicinterest').innerHTML = "Public Interest " + publicinterest.toFixed(1) + '%';
}
}
}
}
//console.log('sellingpriceint', sellingprice);
//console.log('publicinterestint', publicinterest);
//console.log('rubberbandsint', rubberbands)
},100)
此代码描述了 4 个变量。公共利益是旨在增加销售额的事件,具体取决于销售额的高低。售价是您出售橡皮筋的金额,因此公众利益越高,价格越低。公共利益决定者,基本上是利润以及我将如何通过升级来增加公共利益。unsoldrubberbands 只是库存。金钱是不言自明的。所以我真正在寻找的是一个更好的公式,它会根据公共利益成倍地发挥作用,并且无论公共利益是什么都有效。(请记住,公共利益本身只是一个数字,但在显示屏上我在它旁边添加了一个百分比符号)