MISC: small fixes (#270)

* infiltration gain bug fix
* fix corp division description
* avoid some issues with Infinity at super high NFG levels
Co-authored-by: Daniel Perez Alvarez <danielpza@protonmail.com>
This commit is contained in:
Mughur 2023-01-02 20:51:59 +02:00 committed by GitHub
parent dfa691784c
commit 1baa615def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 15 deletions

@ -466,11 +466,12 @@ Path 1 (new):
is extremely powerful, as it raises all multipliers by a significant amount. This also a let's you
get used to augments and other features resetting.
2. Do **BitNode-3: Corporatocracy** once to unlock the Corporation mechanic. This mechanic
has highest profit potential in the game.
2. Do **BitNode-3: Corporatocracy** at least once to unlock the Corporation mechanic, finishing all
3 levels unlocks the full API for free allowing fully scripted corp. This mechanic has highest
profit potential in the game.
3. Do **BitNode-10: Digital Carbon** once to unlock sleeves and grafting. Sleeves are useful in all nodes
and grafting can be useful in future BitNodes (especially 8). It's recommended to buy all sleeves and
and grafting can be useful in future BitNodes (especially 8). It's recommended to buy all purchasable sleeves and
their memory during the first run.
The ordering of the next three is dependant on playing style and wants/needs.

@ -107,6 +107,7 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal
}
export function processPassiveFactionRepGain(numCycles: number): void {
if (Player.bitNodeN === 2) return;
for (const name of Object.keys(Factions)) {
if (isFactionWork(Player.currentWork) && name === Player.currentWork.factionName) continue;
if (!Factions.hasOwnProperty(name)) continue;

@ -9,7 +9,7 @@ export interface FormulaGang {
}
export function calculateWantedPenalty(gang: FormulaGang): number {
return gang.respect / (gang.respect + gang.wantedLevel);
return Math.max(gang.respect + 0.0001) / (gang.respect + gang.wantedLevel);
}
export function calculateRespectGain(gang: FormulaGang, member: GangMember, task: GangMemberTask): number {

@ -38,14 +38,12 @@ export function Victory(props: IProps): React.ReactElement {
const isMemberOfInfiltrators = Player.factions.includes(FactionNames.ShadowsOfAnarchy);
function sell(): void {
handleInfiltrators();
Player.gainMoney(moneyGain, "infiltration");
quitInfiltration();
}
function trade(): void {
if (faction === "none") return;
handleInfiltrators();
Factions[faction].playerReputation += repGain;
quitInfiltration();
}

@ -3938,6 +3938,7 @@ interface HackingFormulas {
hackPercent(server: Server, player: Person): number;
/**
* Calculate the percent a server would grow to.
* Not exact due to limitations of mathematics.
* (Ex: 3.0 would would grow the server to 300% of its current value.)
* @param server - Server info from {@link NS.getServer | getServer}
* @param threads - Amount of thread.
@ -4615,11 +4616,11 @@ export interface NS {
*
* Use your hacking skills to increase the amount of money available on a server.
* The runtime for this command depends on your hacking level and the target servers
* security level. When `grow` completes, the money available on a target server will
* be increased by a certain, fixed percentage. This percentage is determined by the
* target servers growth rate (which varies between servers) and security level. Generally,
* higher-level servers have higher growth rates. The {@link NS.getServerGrowth | getServerGrowth} function can be used
* to obtain a servers growth rate.
* security level. When `grow` completes, the money available on a target server will be increased
* by amount equal to the number of threads used and a certain, fixed percentage of current money on
* the server. This percentage is determined by the target servers growth rate (which varies between servers)
* and security level. Generally, higher-level servers have higher growth rates.
* The {@link NS.getServerGrowth | getServerGrowth} function can be used to obtain a servers growth rate.
*
* Like {@link NS.hack | hack}, `grow` can be called on any server, regardless of where the script is running.
* The grow() command requires root access to the target server, but there is no required hacking
@ -4773,6 +4774,8 @@ export interface NS {
* the amount of money available on the specified server by the specified amount.
* The specified amount is multiplicative and is in decimal form, not percentage.
*
* Due to limitations of mathematics, this function won't be the true value, but an approximation.
*
* Warning: The value returned by this function isnt necessarily a whole number.
*
* @example

@ -183,14 +183,15 @@ export function numCycleForGrowthCorrected(server: Server, targetMoney: number,
*/
let bt = exponentialBase ** threadMultiplier;
if (bt == Infinity) bt = 1e300;
let corr = Infinity;
// Two sided error because we do not want to get stuck if the error stays on the wrong side
do {
// c should be above 0 so Halley's method can't be used, we have to stick to Newton-Raphson
const bct = bt ** cycles;
let bct = bt ** cycles;
if (bct == Infinity) bct = 1e300;
const opc = startMoney + cycles;
const diff = opc * bct - targetMoney;
let diff = opc * bct - targetMoney;
if (diff == Infinity) diff = 1e300;
corr = diff / (opc * x + 1.0) / bct;
cycles -= corr;
} while (Math.abs(corr) >= 1);

@ -275,7 +275,7 @@ const Engine: {
if (Player.currentWork !== null) {
Player.focus = true;
Player.processWork(numCyclesOffline);
} else {
} else if (Player.bitNodeN !== 2) {
for (let i = 0; i < Player.factions.length; i++) {
const facName = Player.factions[i];
if (!Factions.hasOwnProperty(facName)) continue;