![]() Because they are different, it doesn't make sense to have the hack() and grow() in the same script. Now, given you hack() with x threads, you need to grow() for 'y' threads to bring it back up to maximum money again. But, no matter how many threads you give it, the hack will take the same amount of time. ![]() If you give it 5 threads, it will steal 5 times as much money as just one thread. If a server is at maximum money and minimum security, you can call a script with just a single hack, giving it 'x' threads, x being whatever you want. That's the first thing you need to realize. For anything else you only need 1 thread. There are only 3 functions that benefit from more than just one thread, and those are hack(), grow(), and weaken(). Because it feels slow when running with massive threads, which takes about 70% of the money from server and take an hours to grow and weaken. Actually I'm wondering will that be more effective if we have 3 sessions, one doing grow, one doing hack, and one doing weaken at the same time, and with some calculation we can give it different amount of threads to keep it balanced. yeah that sounds like a lot of work compare to its reward. Something else I feel I should probably clarify: the central hubs run on my home server and start scripts on other servers with the 'ns.exec()' function. Wait, maybe I still have an older (smaller) version I could clean up quickly, hmm, nope, those are from before I started using JSON data files to share data between scripts, so they have an extremely strange form (using global script variables to pass data into a script run-time by starting that script again with keyword arguments and it was awful on the level of: don't try this at home kids!). All the managing is done in the central hub (which is too big to post here, plus it looks afwul, I really need to clean that script up some time). It seriously does nothing else than hack and then stop running. The one-shot scripts don't need to know anything apart from the target. My first version just did a very simple 'await ns.sleep(ns.getWeakenTime()) ' after weakening (and the grow and hack time equivalents after growing and hacking). It kind of depends on how far you want to go, my current hub script has quite a bit of complex time calculations (well the calculations aren't that complext, but there are just a lot of them, which makes the code pretty complex to read), so that it can time loops of hack/grow/weaken so that I can hack the server with optimal conditions every three seconds (I took a relatively large safety margin in the timing).īut! That's just the current version, which I wouldn't recommend building from scratch (it took quite a bit of effort even without building it from scratch). For example, what should I do if I'd like to know when my hack() thread is done so I can start another run? I was wondering how were you keep track of the status of each thread. So you are moving the "GetCurrentMoney" thing into the one-shot code? (and technically I have a script above that so that I can have multiple hubs running, so one hub only has to worry about one target) The central hub takes care of everything else, so: timing, what script to run, where to run it, what to target, how many threads to use, and so on. (but at low amounts of ram, the overhead becomes a bit of a bottleneck) This means that the more ram I have available, the more efficient the system gets. The overhead on the central hub is relatively large, but all hack, grow and weaken scripts (which are just that, one script that weakens once, one script that grows once and one script that hacks one) are really small (hack is 1.7GB, grow is 1.75GB and weaken is also 1.75GB). This allows for the program to be run normally, just with this instance of a thread allowing you to cheat the stack limit.Originally posted by Suikoudan:I use a central hub to distribute one-shot scripts. join() will wait for the thread to finish before continuing. The other thing to note if you're unfamiliar with threads (like I was) is that you need to. ![]() Things to note are that if you want to get values back from the threads, you need to store them (and pass them) as mutable objects like lists. X = threading.Thread(target=recurThread, args=(900, y, z)) New_t = threading.Thread(target=recurThread, args=(900, new_y, z)) In my final product I implement multithreading into my backtracking algorithm. I hate multithreading generally, but this is a very basic version of that. I didn't honestly know if this would work before I tried it. To solve this, I had the wild idea of using multithreading to give me multiple stacks. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |