Then instead of using all available memory for starting grow, use half. Figure out a way to see how long weaken() and grow() will take (hint: the documentation – has functions for this). Thus, if we start our weaken before the grow finishes, it will be way faster. The time taken by weaken(), grow() and hack() is calculated by the server and player status at the start of the operation. What if we could start weakening while the grow is in progress, thus doing the tasks in parallel? We actually can: In my case, the obvious time sink was the weaken directly after grow, because the grow increased security significantly. Start by printing to log the time spent on each step. Let’s assume we’ve gotten to the point where a server is prepped (min security and max money reached) so that our loop is approximately weaken -> grow -> weaken -> hack. In general for optimizations, it’s important to measure what parts of our algorithms has the longest impact on performance.
#Hack run zero walkthrough for free
If the control script takes approximately twice the ram of a single thread of weaken.ns, grow.ns or hack.ns, we get 2 additional threads on each of our rooted servers for free by using this technique. The goal here is to write a control script that we run on our home computer, which can spawn weaken.ns grow.ns and hack.ns on other servers – leaving us with all their memory free for doing important jobs. But if we take a look at what the control script is doing, it becomes obvious that we can centralize it.
But if we analyze ram usage on our rooted servers, we see that the actual weaken.ns, grow.ns and hack.ns scripts don’t use all the available ram because the control script takes up quite a chunk. If you deploy this hacking script to each server you have root on, you should be progressing quite well.
Using this technique, depending on your server ram, you will likely double your hacking income and exp. Repeat this process for grow() and hack(). Then, find a way to wait until it finishes. Then take your hacking script from the tutorial, and instead of running weaken() directly, find a way to run the weaken script and passing the target to it as an argument, using as many threads as free ram allows.
#Hack run zero walkthrough how to
To let us run our important functions with as many threads as possible, figure out how to make the simplest possible script that will run weaken() on a target given by argument and nothing more. Separating our hacking scripts to optimize ram usage Since only weaken() grow() and hack() benefit from using additional threads, having each one in a separate script will reduce the ram cost of using additional threads and thus increase our hacking gains a lot.Īt this point it’s worth having the API documentation – handy. When writing scripts you might notice that their ram requirements increase as you use more ns functions. Note that speed here refers to the execution time, not how fast your weaken() grow() and hack() functions run – that is determined by hacking skill. Netscript2 is very close to modern javascript, and their speed is only limited by your computer.
script files which are used in the tutorial, are slow and low on features. The first step is to start using netscript2 – . You might think it’s slow (and you’d be right) and that’s because there are several improvements you can make. In addition the the ingame tutorial, there’s a good guide on how to get a decent hacking script started in the online documentation – .Īt this point you have a script that will continuously weaken, grow and hack a given server. Hacking scripts: How to improve 1: Follow the tutorial This is a spoiler free guide that points you in the right direction.
Finished the tutorial and wondering how to progress? Want to improve your hacking script or maybe you want to start automating other parts of the game?