This file contains hidden or 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
const HALF_EPS = Number.EPSILON / 2; | |
/** | |
* Determines whether a number is a power of two, using floating-point heuristics | |
* | |
* @param num - The number to test | |
* @returns True if the number is a power of two; false otherwise | |
*/ | |
export function isPowerOfTwo(num: number) : boolean { | |
// Check for very small numbers to account for floating point precision issues |
This file contains hidden or 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
import * as Utils from 'utilities'; | |
const MAX_SECUIRTY_DRIFT: number = 3; // How far from minimum security we allow the server to be before weakening | |
const MAX_MONEY_DRIFT_PCT: number = 0.1; // How far from 100% money we allow the server to be before growing (1-based percentage) | |
const DEFAULT_PCT: number = 0.25; // The default 1-based percentage of money we want to hack from the server in a single pass | |
const MIN_HOME_RAM: number = 64; // Number of GBs we want to keep free on `home` | |
export async function main(ns: NS) { | |
ns.disableLog("ALL"); |
This file contains hidden or 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
/** | |
* Attempts to nuke a given `host` | |
* | |
* @remarks RAM cost: 3.85 GB | |
* @param host - The name of the host server to nuke | |
* @return True if the server was successfully nuked; otherwise false | |
*/ | |
export function nukeServer(ns: NS, host: string) : boolean { | |
if (!canNukeServer(ns, host)) | |
return false; |