mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-23 12:42:34 +00:00
update break_infinity.js from upstream
This commit is contained in:
parent
f1b3a7d2dd
commit
def1ba642d
@ -404,51 +404,51 @@
|
||||
Decimal.cbrt = function (value) {
|
||||
return D(value).cbrt();
|
||||
};
|
||||
/**
|
||||
* If you're willing to spend 'resourcesAvailable' and want to buy something
|
||||
* with exponentially increasing cost each purchase (start at priceStart,
|
||||
* multiply by priceRatio, already own currentOwned), how much of it can you buy?
|
||||
* Adapted from Trimps source code.
|
||||
/**
|
||||
* If you're willing to spend 'resourcesAvailable' and want to buy something
|
||||
* with exponentially increasing cost each purchase (start at priceStart,
|
||||
* multiply by priceRatio, already own currentOwned), how much of it can you buy?
|
||||
* Adapted from Trimps source code.
|
||||
*/
|
||||
|
||||
|
||||
Decimal.affordGeometricSeries = function (resourcesAvailable, priceStart, priceRatio, currentOwned) {
|
||||
return this.affordGeometricSeries_core(D(resourcesAvailable), D(priceStart), D(priceRatio), currentOwned);
|
||||
};
|
||||
/**
|
||||
* How much resource would it cost to buy (numItems) items if you already have currentOwned,
|
||||
* the initial price is priceStart and it multiplies by priceRatio each purchase?
|
||||
/**
|
||||
* How much resource would it cost to buy (numItems) items if you already have currentOwned,
|
||||
* the initial price is priceStart and it multiplies by priceRatio each purchase?
|
||||
*/
|
||||
|
||||
|
||||
Decimal.sumGeometricSeries = function (numItems, priceStart, priceRatio, currentOwned) {
|
||||
return this.sumGeometricSeries_core(numItems, D(priceStart), D(priceRatio), currentOwned);
|
||||
};
|
||||
/**
|
||||
* If you're willing to spend 'resourcesAvailable' and want to buy something with additively
|
||||
* increasing cost each purchase (start at priceStart, add by priceAdd, already own currentOwned),
|
||||
* how much of it can you buy?
|
||||
/**
|
||||
* If you're willing to spend 'resourcesAvailable' and want to buy something with additively
|
||||
* increasing cost each purchase (start at priceStart, add by priceAdd, already own currentOwned),
|
||||
* how much of it can you buy?
|
||||
*/
|
||||
|
||||
|
||||
Decimal.affordArithmeticSeries = function (resourcesAvailable, priceStart, priceAdd, currentOwned) {
|
||||
return this.affordArithmeticSeries_core(D(resourcesAvailable), D(priceStart), D(priceAdd), D(currentOwned));
|
||||
};
|
||||
/**
|
||||
* How much resource would it cost to buy (numItems) items if you already have currentOwned,
|
||||
* the initial price is priceStart and it adds priceAdd each purchase?
|
||||
* Adapted from http://www.mathwords.com/a/arithmetic_series.htm
|
||||
/**
|
||||
* How much resource would it cost to buy (numItems) items if you already have currentOwned,
|
||||
* the initial price is priceStart and it adds priceAdd each purchase?
|
||||
* Adapted from http://www.mathwords.com/a/arithmetic_series.htm
|
||||
*/
|
||||
|
||||
|
||||
Decimal.sumArithmeticSeries = function (numItems, priceStart, priceAdd, currentOwned) {
|
||||
return this.sumArithmeticSeries_core(D(numItems), D(priceStart), D(priceAdd), D(currentOwned));
|
||||
};
|
||||
/**
|
||||
* When comparing two purchases that cost (resource) and increase your resource/sec by (deltaRpS),
|
||||
* the lowest efficiency score is the better one to purchase.
|
||||
* From Frozen Cookies:
|
||||
* http://cookieclicker.wikia.com/wiki/Frozen_Cookies_(JavaScript_Add-on)#Efficiency.3F_What.27s_that.3F
|
||||
/**
|
||||
* When comparing two purchases that cost (resource) and increase your resource/sec by (deltaRpS),
|
||||
* the lowest efficiency score is the better one to purchase.
|
||||
* From Frozen Cookies:
|
||||
* http://cookieclicker.wikia.com/wiki/Frozen_Cookies_(JavaScript_Add-on)#Efficiency.3F_What.27s_that.3F
|
||||
*/
|
||||
|
||||
|
||||
@ -472,20 +472,20 @@
|
||||
mantissa *= Math.sign(Math.random() * 2 - 1);
|
||||
var exponent = Math.floor(Math.random() * absMaxExponent * 2) - absMaxExponent;
|
||||
return ME(mantissa, exponent);
|
||||
/*
|
||||
Examples:
|
||||
randomly test pow:
|
||||
var a = Decimal.randomDecimalForTesting(1000);
|
||||
var pow = Math.random()*20-10;
|
||||
if (Math.random()*2 < 1) { pow = Math.round(pow); }
|
||||
var result = Decimal.pow(a, pow);
|
||||
["(" + a.toString() + ")^" + pow.toString(), result.toString()]
|
||||
randomly test add:
|
||||
var a = Decimal.randomDecimalForTesting(1000);
|
||||
var b = Decimal.randomDecimalForTesting(17);
|
||||
var c = a.mul(b);
|
||||
var result = a.add(c);
|
||||
[a.toString() + "+" + c.toString(), result.toString()]
|
||||
/*
|
||||
Examples:
|
||||
randomly test pow:
|
||||
var a = Decimal.randomDecimalForTesting(1000);
|
||||
var pow = Math.random()*20-10;
|
||||
if (Math.random()*2 < 1) { pow = Math.round(pow); }
|
||||
var result = Decimal.pow(a, pow);
|
||||
["(" + a.toString() + ")^" + pow.toString(), result.toString()]
|
||||
randomly test add:
|
||||
var a = Decimal.randomDecimalForTesting(1000);
|
||||
var b = Decimal.randomDecimalForTesting(17);
|
||||
var c = a.mul(b);
|
||||
var result = a.add(c);
|
||||
[a.toString() + "+" + c.toString(), result.toString()]
|
||||
*/
|
||||
};
|
||||
|
||||
@ -517,8 +517,8 @@
|
||||
Decimal.efficiencyOfPurchase_core = function (cost, currentRpS, deltaRpS) {
|
||||
return cost.div(currentRpS).add(cost.div(deltaRpS));
|
||||
};
|
||||
/**
|
||||
* When mantissa is very denormalized, use this to normalize much faster.
|
||||
/**
|
||||
* When mantissa is very denormalized, use this to normalize much faster.
|
||||
*/
|
||||
|
||||
|
||||
@ -554,8 +554,8 @@
|
||||
this.normalize();
|
||||
return this;
|
||||
};
|
||||
/**
|
||||
* Well, you know what you're doing!
|
||||
/**
|
||||
* Well, you know what you're doing!
|
||||
*/
|
||||
|
||||
|
||||
@ -954,37 +954,37 @@
|
||||
Decimal.prototype.reciprocate = function () {
|
||||
return this.recip();
|
||||
};
|
||||
/**
|
||||
* -1 for less than value, 0 for equals value, 1 for greater than value
|
||||
/**
|
||||
* -1 for less than value, 0 for equals value, 1 for greater than value
|
||||
*/
|
||||
|
||||
|
||||
Decimal.prototype.cmp = function (value) {
|
||||
var decimal = D(value); // TODO: sign(a-b) might be better? https://github.com/Patashu/break_infinity.js/issues/12
|
||||
|
||||
/*
|
||||
from smallest to largest:
|
||||
-3e100
|
||||
-1e100
|
||||
-3e99
|
||||
-1e99
|
||||
-3e0
|
||||
-1e0
|
||||
-3e-99
|
||||
-1e-99
|
||||
-3e-100
|
||||
-1e-100
|
||||
0
|
||||
1e-100
|
||||
3e-100
|
||||
1e-99
|
||||
3e-99
|
||||
1e0
|
||||
3e0
|
||||
1e99
|
||||
3e99
|
||||
1e100
|
||||
3e100
|
||||
/*
|
||||
from smallest to largest:
|
||||
-3e100
|
||||
-1e100
|
||||
-3e99
|
||||
-1e99
|
||||
-3e0
|
||||
-1e0
|
||||
-3e-99
|
||||
-1e-99
|
||||
-3e-100
|
||||
-1e-100
|
||||
0
|
||||
1e-100
|
||||
3e-100
|
||||
1e-99
|
||||
3e-99
|
||||
1e0
|
||||
3e0
|
||||
1e99
|
||||
3e99
|
||||
1e100
|
||||
3e100
|
||||
*/
|
||||
|
||||
if (this.mantissa === 0) {
|
||||
@ -1153,10 +1153,10 @@
|
||||
Decimal.prototype.compare_tolerance = function (value, tolerance) {
|
||||
return this.cmp_tolerance(value, tolerance);
|
||||
};
|
||||
/**
|
||||
* Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments.
|
||||
* For example, if you put in 1e-9, then any number closer to the
|
||||
* larger number than (larger number)*1e-9 will be considered equal.
|
||||
/**
|
||||
* Tolerance is a relative tolerance, multiplied by the greater of the magnitudes of the two arguments.
|
||||
* For example, if you put in 1e-9, then any number closer to the
|
||||
* larger number than (larger number)*1e-9 will be considered equal.
|
||||
*/
|
||||
|
||||
|
||||
@ -1241,7 +1241,7 @@
|
||||
if (Number.isSafeInteger(temp)) {
|
||||
newMantissa = Math.pow(this.mantissa, numberValue);
|
||||
|
||||
if (isFinite(newMantissa)) {
|
||||
if (isFinite(newMantissa) && newMantissa != 0) {
|
||||
return ME(newMantissa, temp);
|
||||
}
|
||||
} // Same speed and usually more accurate.
|
||||
@ -1251,7 +1251,7 @@
|
||||
var residue = temp - newExponent;
|
||||
newMantissa = Math.pow(10, numberValue * Math.log10(this.mantissa) + residue);
|
||||
|
||||
if (isFinite(newMantissa)) {
|
||||
if (isFinite(newMantissa) && newMantissa != 0) {
|
||||
return ME(newMantissa, newExponent);
|
||||
} // return Decimal.exp(value*this.ln());
|
||||
// UN-SAFETY: This should return NaN when mantissa is negative and value is non-integer.
|
||||
@ -1360,8 +1360,8 @@
|
||||
|
||||
return Decimal.ln(this.add(1).div(new Decimal(1).sub(this))) / 2;
|
||||
};
|
||||
/**
|
||||
* Joke function from Realm Grinder
|
||||
/**
|
||||
* Joke function from Realm Grinder
|
||||
*/
|
||||
|
||||
|
||||
@ -1372,8 +1372,8 @@
|
||||
|
||||
return this.pow(Math.pow(10, -ascensions));
|
||||
};
|
||||
/**
|
||||
* Joke function from Cookie Clicker. It's 'egg'
|
||||
/**
|
||||
* Joke function from Cookie Clicker. It's 'egg'
|
||||
*/
|
||||
|
||||
|
||||
|
2
javascripts/lib/break_infinity.min.js
vendored
2
javascripts/lib/break_infinity.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user