가장 수익성 높은 업그레이드를 찾고 선택하는 Hacknet 노드를 위한 Full Automation.
전달 방법
알고리즘은 가장 수익성 있는 비율을 찾고 있습니다.
비율 = 생산 성장 로 나눈 업그레이드 비용
생산 성장 = 업그레이드 후 생산 로 나눈 현재 생산
나는 너를 추천한다. 더 큰 루프 반복 시간(예: 100)을 전달하거나 hacknet 노드가 가장 저렴한 업그레이드를 지속적으로 업그레이드하는 대신 더 많은 업그레이드를 비교할 수 있도록 더 많은 돈을 모으도록 기본값을 그대로 두십시오.
용법
단계별
- 터미널 열기
- "nano hacknet-bot.ns"를 입력하여 파일 생성
- 파일을 지우고 아래에 코드를 붙여넣으세요.
- 파일 저장
- 터미널로 돌아가기
- 스크립트를 실행하려면 "run hacknet-bot.ns"를 입력하십시오.
추가 스크립트 인수를 전달하여 루프 빈도 시간을 정의할 수 있습니다.
예: "hacknet-bot.ns 10000 실행"
기본 루프 주파수 60ms = 000분입니다.
다음에서 코드를 복사할 수도 있습니다. https://www.paste.org/121034.
암호
/** @param {NS} ns **/ export const main = async ns => { // helpers const getMoney = () => ns.getPlayer().money; const getProduction = (level, ram, cores) => (level * 1.5) * Math.pow(1.035, ram - 1) * ((cores + 5) / 6); // loop interval passed as a script parameter, default interval is 60 000ms const interval = ns.args[0] || 60000; // main loop while (true) { // loop through all hacknet nodes for (var index = 0; index < await ns.hacknet.numNodes(); index++) { // your current money const money = getMoney(); // your production multiplier from installed augmentations const prodMultiplier = await ns.getHacknetMultipliers().production; // get current node stats const nodeStats = await ns.hacknet.getNodeStats(index); const curRam = nodeStats.ram; const curLevel = nodeStats.level; const curCores = nodeStats.cores; const curProd = nodeStats.production; // get costs of upgrades const ramUpgradeCost = await ns.hacknet.getRamUpgradeCost(index); const levelUpgradeCost = await ns.hacknet.getLevelUpgradeCost(index); const coreUpgradeCost = await ns.hacknet.getCoreUpgradeCost(index); // check upgrades profitability and if you have enough money // UPGRADE RATIO = production growth after upgrade / current production const prodGrowthAfterLevelUpgrade = (getProduction(curLevel + 1, curRam, curCores) * prodMultiplier) - curProd; const levelUpgradeRatio = money >= await levelUpgradeCost ? prodGrowthAfterLevelUpgrade / await levelUpgradeCost : 0; const prodGrowthAfterRamUpgrade = (getProduction(curLevel, curRam * 2, curCores) * prodMultiplier) - curProd; const ramUpgradeRatio = money >= await ramUpgradeCost ? prodGrowthAfterRamUpgrade / await ramUpgradeCost : 0; const prodGrowthAfterCoresUpgrade = (getProduction(curLevel, curRam, curCores + 1) * prodMultiplier) - curProd; const coresUpgradeRatio = money >= await coreUpgradeCost ? prodGrowthAfterCoresUpgrade / await coreUpgradeCost : 0; // check if you have enough money for any upgrade const ratios = [levelUpgradeRatio, ramUpgradeRatio, coresUpgradeRatio]; if (ratios.every(ratio => ratio === 0)) { continue; } // find the most profitability upgrade const mostProfitUpgrade = Math.max(...ratios); const mostProfitUpgradeIndex = ratios.findIndex(ratio => ratio === mostProfitUpgrade); // execute the most profitability upgrade switch (mostProfitUpgradeIndex) { case 0: await ns.hacknet.upgradeLevel(index, 1); break; case 1: await ns.hacknet.upgradeRam(index, 1); break; case 2: await ns.hacknet.upgradeCore(index, 1); break; default: continue; } } // check if you can buy new node machine if (getMoney() > await ns.hacknet.getPurchaseNodeCost()) { await ns.hacknet.purchaseNode(); } // sleep to prevent crash because of infinite loop await ns.sleep(interval); } }
By syw1
더 많은 가이드:
- Bitburner: 초기 Hacknet 자동 관리 스크립트
- Bitburner: Combat Gang Management 스크립트(완전 자동)
- Bitburner: HUD에 사용자 지정 통계를 추가하는 방법(헤드업 디스플레이)
- Bitburner: 초기 게임 가이드(스포일러 없음)
- Bitburner: DevMenu 성취 가이드
맙소사.. 만약 당신이 코드를 훔쳐 게시할 생각이라면 - 적어도 읽을 수 있게 하라…
이건 쓰레기야