Published in


Managing Hacknet Nodes in Bitburner

For those that are not aware bitburner is a semi-idle game that encourages scripting to get things done. I say semi-idle — it certainly meets the criteria for an idle game in that it apparently runs offline, and picks up when you play the next day. However, the programming aspect is quite immersive, and makes it much less idle than most.

Photo by Nikita Bandaruk on Unsplash

One of the best bits is that it includes and even encourages one's programming skills. Despite being a web developer most of my focus tends to be in the backend, APIs and DevOps. One of my most overlooked technologies is javascript.

This is a quick walkthrough of my scripts to control the hacknet aspect of the game. The hacknet are a series of virtual computers that raise funds through rent, which garner more rent the more powerful they become. Initially, I simply upgraded each node to the max and moved on. However on a small analysis I realised that might not be the most appropriate strategy.

Essentially with the hacknet you can do 4 things, you can upgrade the three components (Level, Ram, or Number of cores), or buy a new node. The cost of doing each of these things and the reward changes as one purchases more. The key is determining how far to go before the reward diminishes.there are a number of strategies suggested throughout the web, but the beauty of scripting is that you can get better strategies.

The first step in deciding the strategy is determinng what metric one is lookng at. What are we maxmising or minimising.for the hacknet simulation I suggest that it should be the pay back time. Ie if I do a thing X, and it costs Y, and improves producton by Z how many seconds will it take to recoup the cost?

Once the strategy is decided, one can code to select the best action on the best node to apply it on. Getting some of the necessary information is a little tricky — you essentially have two options. Buy the formulas API each time you restart, or refer to the source code. For example the hacknet formulae are all in the same file — including this easy to transcribe function for working out the production rate of a server with given values. In lines 81–92 above the second function is from the original source, the first was originally pointing towards the formulas API method.

My full original code is available via this gist.

I ran this straight after a restart, to see how it would fare running alone. Mileage may vary, but after an hour here s the result;

1 hour after a restart

Whats interesting to note — At the start of the process, all three properties seem to get upgraded fairly levelly, with the second node occuring just after the level Maxes. The ram maxes out just after the subsequent node appears. Cores seem to reach a limit. There s a conditon in the script that states that every action should be able to pay for itself within 12 hours. So Lets see where this ends up.

For those interested I’m on Corporatocracy Lvl1. So that might slow things down a bit. Although the extra money from the corporation speeds things up too.




Everything connected with Tech & Code. Follow to join our 900K+ monthly readers

Recommended from Medium

5 Rules about Catching Exceptions in Java

Custom/Ad-Hoc Reporting in Qlik Sense

Gitlab HTTP Basic: Access denied and fatal:Authentication failed

Escalate My Privilege 1

Devlog 28: Added A Charged Shot To My Game

Dataflows vs Dashboards — What to use and when?

Extracting text from images with Tesseract OCR, OpenCV, and Python

Creating a VR Experience in Unity

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Brian Jones

Brian Jones

Coder, Dad,

More from Medium

NGINX Made Easier with GUI

Earning passive income with Hodlnaut and CryptoParrot

NovaX Launches New Website. Clone