下载客户端

完全自动化 - 黑客网络管理器(适用于所有升级)

2026-02-15 22:00:10
发布在Bitburner
转载

AI智能总结导读

这是一款适用于游戏Bitburner的黑客网络管理器自动化脚本,占用5.7GB内存,支持ES5和ES6两种版本,能自动选择最便宜的黑客网络升级选项,等资金足够时完成购买,实现收益最大化,还附详细的脚本创建、使用步骤及代码。

RAM Usage: 5.7GB This script will fully automate the purchase of all Hacknet upgrades in the fastest method possible. The fastest method is exponential returns awarded through selecting the cheapest upgrade at all times, therefore making your money work for you faster. Determine the cheapest upgrade, wait for funds, purchase, rinse and repeat. Create ES5 Script This script utilises ES5 JavaScript interpreter, otherwise referenced as Netscript 1.0 meaning a file extension of .script is required. While inside the Bitburner Terminal create a new script by typing the following: nano nameOfYourFile.script Example: nano hacknet_infinite.script Note: This script requires 5.7GB of memory available Alternative - Create ES6 Script This script utilises ES6 JavaScript interpreter, otherwise referenced as Netscript 2.0 meaning a file extension of .js is required. This alternative script has been provided by Caladrel While inside the Bitburner Terminal create a new script by typing the following: nano nameOfYourFile.js Example: nano hacknet_infinite.js Note: This script requires 5.7GB of memory available Script Code ES5.script Copy the contents of the script and save into the new script file you just created. // Create Function to Return Balance function myMoney() { return getServerMoneyAvailable("home"); } // Disable Logging for the Following Commands Below (We Dont Want To See Them While we Wait for Our Balance to Grow) disableLog("getServerMoneyAvailable"); disableLog("sleep"); // Create Function to Purchase Upgrade Based on 3 Flags for Node, Item, Qty // # Note Qty is not utilised but the Framework is in Place to Future Proof function purchase(node, item, qty){ var node = node, item = item, qty = qty; if (item == "New Node"){ hacknet.purchaseNode(); print("Purchasing New Node") } if (item == "LVL"){ hacknet.upgradeLevel(node , qty) print("Purchasing LVL Upgrade for Node: " + node) } if (item == "RAM"){ hacknet.upgradeRam(node , qty) print("Purchasing RAM Upgrade for Node: " + node) } if (item == "CPU"){ hacknet.upgradeCore(node , qty) print("Purchasing CPU Upgrade for Node: " + node) } } // Create Function to Find the Cheapest Upgrade and Set Flags to be Used by the Purchase Function // We will set the Default Flags to Purchase a New Node, Only to be Overwritten if a Cheaper Option is Available function check_cheapest() { var new_node_cost = hacknet.getPurchaseNodeCost(); var node = "Default"; var item = "New Node"; var qty = 1; var cheapest = new_node_cost; var node_qty = hacknet.numNodes(); // Iterate Through all Node Upgrade Options, Overwrite Flags if Cheaper Upgrade is Found for (var i = 0; i < node_qty; i++) { var node_lvl = hacknet.getLevelUpgradeCost(i, 1); var node_ram = hacknet.getRamUpgradeCost(i, 1); var node_cpu = hacknet.getCoreUpgradeCost(i, 1); if (node_lvl < cheapest) { cheapest = node_lvl; node = i; item = "LVL"; } if (node_ram < cheapest) { cheapest = node_ram; node = i; item = "RAM"; } if (node_cpu < cheapest) { cheapest = node_cpu; node = i; item = "CPU"; } } // I am not a JavaScript Programmer so I am not Adept at String Manipulation in this Language // Print a Summary Log of Cheapest Upgrade Found // Thanks @Dr. Red print( " n" + "Cheapest Hacknet Upgrade Available:" + " n" + "Node : " + node + " n" + "Item : " + item + " n" + "Qty : " + qty + " n n" + "Current Balance : $" + myMoney() + " n" + "Upgrade Cost : $" + cheapest + " n" ) // After Determining the Cheapest Upgrade we will wait for Balance to Increase Enough to Purchase (This is why we turned off logging) while (myMoney() < cheapest) { print("Waiting for funds to increase") sleep(3000); } // Call the Purchase Function purchase(node, item, qty); } // Run the Cheapest Upgrade Function in an Infinite Loop while(true) { check_cheapest() } Alternative - Script Code ES6.js Copy the contents of the script and save into the new .js file you just created. /** @param {NS} ns **/ export async function main(ns) { while(true) { // Check optimal purchase var nodeNum = "Default"; var itemType = "New Node"; var cheapest = ns.hacknet.getPurchaseNodeCost(); var num_nodes = ns.hacknet.numNodes(); // Iterate through all nodes and select lowest purchase/upgrade available for (var i = 0; i < num_nodes; i++) { var level_cost = ns.hacknet.getLevelUpgradeCost(i, 1); var ram_cost = ns.hacknet.getRamUpgradeCost(i, 1); var cpu_cost = ns.hacknet.getCoreUpgradeCost(i, 1); if (level_cost < cheapest) { cheapest = level_cost; nodeNum = i; itemType = "Level"; } if (ram_cost < cheapest) { cheapest = ram_cost; nodeNum = i; itemType = "RAM"; } if (cpu_cost < cheapest) { cheapest = cpu_cost; nodeNum = i; itemType = "CPU"; } } // If affordable, purchase and recalculate above var purchased = false; while (!purchased) { var money = ns.getServerMoneyAvailable("home"); if (money >= cheapest) { if (itemType == "New Node"){ ns.hacknet.purchaseNode(); } if (itemType == "Level"){ ns.hacknet.upgradeLevel(nodeNum , 1); } if (itemType == "RAM"){ ns.hacknet.upgradeRam(nodeNum , 1); } if (itemType == "CPU"){ ns.hacknet.upgradeCore(nodeNum , 1); } purchased = true; } // If we didn't purchase, wait 1 second and try again if(!purchased) { await ns.sleep(1000); } } } } Usage After saving the script you can run it by typing: run nameOfYourScript.script Example: run hacknet_infinity.script Alternatively if you went for the ES6 option run your code by typing: run nameOfYourScript.js Example: run hacknet_infinity.js Under the Hood This script iterates through all upgrade options, sets flags for the cheapest option and waits until there is enough funds to purchase. Currently it does not utilise the quantity function, as the cheapest option is always to purchase in single units to get your money working for you faster under the passive income method. This is why the variable Qty is set to 1 and not overwritten in the loop. If you read through the Hacknet API on the official website there is an example script which uses a value of 10 when purchasing basic levels for Nodes. IMO buying single units will net you more money in the long run due to exponential returns from the smaller purchases of single levels. Please see below screen shots below to see how IMBA this script is to your crash flow.

评论

共0条评论
face
inputImg
相关阅读
最新更新

最新更新

  • Bitburner 新手合约指南 — A short guide and simple working scripts for solving Bitburner Coding Contracts.…
  • Bitburner 新手脚本指南 — 这是我为《网络黑客》创建/找到的中级脚本集合。它们基于我之前指南中的许多脚本。 查找元数据 元数据基本上是无法通过数据库或数学函数推导的数据。我构建了一个元数据…
  • 为HUD(平视显示器)添加自定义数据 — 使用内置的隐藏钩子和少量脚本自定义你的状态显示界面。 探索发现 本游戏鼓励你超越用户界面和文档进行探索。你可以检查文档对象模型,甚至查看源代码本身。当你开始跳出…
  • 我的《网络骇客》新手笔记、批处理脚本与部署方案 — Useful for beginners, this guide provides: -The Tutorial Commands in order -Cont…
  • 派系与强化 — I asked for this. ㅤ * acquired only from this faction, grafting and certain gang…
  • 基础黑客网络管理器 — 一个用于管理你的黑客网络的基础代码,同时尽量避免花费过多资金 使用方法: 创建一个.js文件或.ns文件,这两种都可以,.script文件使用不同的标准,所以不…
  • 实用脚本【备份】 — I need some place to keep my very useful scripts. Feel free to copy them! Some o…
  • 简易黑客网络管理器 — 一个简单的黑客网络管理器,可高效为你购买所有黑客网络升级。 设置步骤: 1. 创建一个.js文件并粘贴以下代码 2. 输入命令:nano nameOfYourF…
  • 一些实用的别名 — 早期游戏中的一些实用别名 别名 正如游戏内帮助所述,别名功能允许用一个字符串替换另一个单词。游戏还提供了示例:alias "nuke=run NUKE.exe"…
  • 《比特燃烧者》新手黑客指南 — A short & comprehensive guide including simple working scripts for beginning…