Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gym to train stats (#107) update #303

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

Arthan-the-one
Copy link
Contributor

@Arthan-the-one Arthan-the-one commented May 31, 2023

-should now respect focus settings
-calculates that training can finish before traveling to gym
--(including backdoor discount)
-code deduplication/refactoring
-only attempt to travel if in wrong city
-option no-gym to disable gym
-split gym logic from crime logic, crime first
-correct eta-calc on bitnodes with stat multipliers
-use best gym available with current money, including travel expenses

Already in the original MR:
-ETA for training
-logic for price calculation
-the training itself
-travel to city of best gym

ToDo:
-push karma to -52k if gangs are unlocked before using the gym - maybe make configurable/be intelligent about it, might take a lot of time
-consider adding option to limit training money

fixes #107

Bindygames and others added 11 commits February 18, 2023 02:14
Greatly increases the time to get required stats.
In the later version the karma stat would get higher up than required while the combat stats weren't increasing at the same rate.
Added an ETA to the completion time of a required stat.
Next feature will check if the player has enough money to start working at the gym.
work-for-factions.js Show resolved Hide resolved
gymCost = await getGymCost(await getSkillEta(stats[currentStat], reqStats, player)),
travelCost = (player.city != bestGymCity) ? 200000 : 0

if ((player.money - travelCost) < gymCost) return ns.print(`Warn: You're too poor to finish training, get at least ${gymCost + travelCost} money`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple questions / suggestions:

  • If we cannot afford to travel to the gym of our choosing, should we not fall-back to whatever gym is in the current city, and only return a warning like this if there is no gym available?
  • Similar to what is in sleeves.js, we need to detect if the player is traning into negative money, and prevent that from happening. There should probably be similar associated options (command line parameters) that limit training by money and/or by time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added use of best available gym for our money.
the training only starts when we have enough money to finish it, so we shouldn't go negative

Copy link
Owner

@alainbryden alainbryden Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scripts can't count on other scripts not to spend money, so it's great that you can check up front but you still do have to continuously monitor money and stop if it starts to get low.

work-for-factions.js Outdated Show resolved Hide resolved
let crime, lastCrime, crimeTime, lastStatusUpdateTime, needStats;
while (forever || (needStats = anyStatsDeficient(player)) || player.numPeopleKilled < reqKills || -ns.heart.break() < reqKarma) {
let crime, lastCrime, crimeTime, lastStatusUpdateTime;
while (forever || player.numPeopleKilled < reqKills || -ns.heart.break() < reqKarma) {
Copy link
Owner

@alainbryden alainbryden May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the feature request: #107
It was suggested that if Gangs are unlocked (BN2), we should always prioritize "training" via crime (e.g. Karma generating actions) until we have the -52K karma required to join a gang, and only resort to gym-training after the gang.

Once we've abstracted this a bit more to have a clear upfront "decision" on whether to use crime or gym to train, we can add some logic to that decision-making process to favour crime if we're not yet in a gang. We can re-use the options['no-crime'] check if ever someone wanted to override this and hit the gym instead.

Another option is that we create a separate function in the main "work loop" that simply prioritizes doing crime for gang requirements before it starts attempting to work for factions (controllable via config options). Then this routine doesn't need any gangs-specific logic and can just focus on the requirements. That's probably the better approach.


That also helped me notice another thing that needs fixing: Everything that calls this "crimeForKillsKarmaStats" function is gated behind a options['no-crime'] check, which will skip it - but now that this function might also be opting to use the gym, we will need to move that check from outside of the function to inside of it, and revise usages to make sure they make sense. We'll probably also want to add an equivalent options['no-gym'] option for anyone wanting to similarily avoid working out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added option no-gym, no-crime now only selects crime.
gangs still ToDo.
only 3 places called the function: crime.js -> altered to call new commitCrime; karma-increasing criming in mainLoop -> commitCrime; earnFactionInvite -> split into crime and gym

@alainbryden alainbryden added enhancement New feature or request work-in-progress not ready for merge labels May 31, 2023
@alainbryden
Copy link
Owner

Thanks for doing the heavy lifting. There are some potential side-effects and "configurability" issues I would like addressed. If there's anything you want to tackle, feel free, otherwise I'm happy to "take over" at any point to polish off the bits I feel are missing.

@s0r3-glitch
Copy link
Contributor

I have been testing this over the past few days and have found that I have had a lot of problems when it comes to ascending. I keep getting errors about an unexpected money change right before buying everything for ascending causing the script to fail out and stop running completely. At one point during 4.3 (i think) I had the issue of it trying to spend 860b on rep well i had something like 2t in raw cash. Now I am not 100% sure that this problem is entirely due to the code in this PR but i figured I would bring it up here since its the code.

@alainbryden
Copy link
Owner

I have been testing this over the past few days and have found that I have had a lot of problems when it comes to ascending. I keep getting errors about an unexpected money change right before buying everything for ascending causing the script to fail out and stop running completely. At one point during 4.3 (i think) I had the issue of it trying to spend 860b on rep well i had something like 2t in raw cash. Now I am not 100% sure that this problem is entirely due to the code in this PR but i figured I would bring it up here since its the code.

A year late, but I think this might be a separate issue #328 - but I appreciate you testing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work-in-progress not ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

work-for-faction.js: Use gym instead of crimes to gain stats (once in a gang)
4 participants