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

BUGFIX: Change generation rate of CCTs #1657

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

catloversg
Copy link
Contributor

When the game loads a save file that has too much bonus time, it tries to generate a massive amount of CCTs. This may take a very long time, and the player will think that the game hangs forever. This PR fixes this problem by changing how we generate CCTs at loading time.

New change: We have a new threshold: 30 days. If the offline time is below this threshold, we generate CCTs as normal; otherwise, we use a new formula to calculate the number of "bonus" CCTs.

Current generation rate: 25% chance of 1 CCT per 10 minutes. Average: 1.5 CCT/hour.

We have 2 formulas:
Current [1]:
$$y = 24 \ast 1.5 \ast x$$
New [2]:
$$y = \frac{6500}{1 + e ^ {-0.02 \ast x + 2.2}}$$

Graph:
Capture

Desmos link: https://www.desmos.com/calculator/pxm0lgovvp

Rationale behind the new change:

  • No change in the generation rate when the player is online or when the offline time is below the threshold, so there is no need to debate about the balance.
  • After being offline for 1 month (~30 days), the player will receive ~1100 bonus CCTs in [1]. Having 1100 bonus CCTs is a decent offline bonus.
  • The cap of [2] is 6500. 6500 CCTs is the amount of CCTs that the player will receive if they are online for half a year without resetting. There is no point in rewarding them more than that. Generating 6500 CCTs is also very fast. On my 8-year-old machine, it takes only ~300ms to do that.

Fixes #1629.

@d0sboots
Copy link
Collaborator

A couple of design comments:

  • I think this should be in the online calculation, not the offline one. (And the offline calculation should just fall through to online calculation.) This both prevents duplication of code and offline-only bugs/behavior, but also fixes the issue where people will adjust the date (setting it to 0 is common when doing exploits, or if you messed up) and then the game freezes attempting to do CCTs.
  • I'd prefer if the backoff were based on current contracts that exist, rather than elapsed time. That way it would serve to absolutely prevent contract spam in the form of multiple large jumps. But that's a nice-to-have.

@catloversg
Copy link
Contributor Author

New update:

  • Unify code of online and offline generation.
  • Chance of generation is based on the number of current contracts.

Chance:
Capture1

Desmos link: https://www.desmos.com/calculator/zzdf958b9g

Number of generated contracts if:

  • Start generating when there are no contracts on any servers.
  • X axis is "month".

Capture2

Raw data:

	Old	New
1	1089.2	1072
2	2173	2123
3	3225.8	3140.1
4	4313.3	4047.8
5	5425.6	4773.7
6	6479.9	5297.9
7	7570.4	5696.9
8	8669.5	5959.3
9	9709.1	6187.8
10	10811.2	6391.4
11	11853.2	6523
12	12953.3	6677.5
13	13991.2	6795.8
14	15151.3	6917.8
15	16202.5	7001.3
16	17311.3	7088.1
17	18407.5	7171.6
18	19458.7	7236.7
19	20513.6	7309.8
20	21621.9	7374
21	22690.6	7428.5
22	23675	7484.8
23	24910.1	7528.7
24	25887.2	7584.2
25	27046.5	7629.4
26	28075.1	7668.6
27	29279.4	7699.9
28	30226.4	7753.9
29	31330.3	7789.9
30	32414	7811.7
31	33572.8	7854.7
32	34544.4	7881.2
33	35634.1	7912.9
34	36679.9	7940.8
35	37838.1	7987.8
36	38922.1	8020.2

@catloversg catloversg changed the title BUGFIX: Change generation rate of bonus CCTs when loading save file BUGFIX: Change generation rate of CCTs Sep 20, 2024
Copy link
Collaborator

@d0sboots d0sboots left a comment

Choose a reason for hiding this comment

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

I was surprised to see that the number of contracts generated online is fixed at 1. Does that mean that the online issue isn't actually this? If you exploit and change the date while BB is running, does it still hang or does this fix it?

src/CodingContractGenerator.ts Outdated Show resolved Hide resolved
src/CodingContractGenerator.ts Outdated Show resolved Hide resolved
src/CodingContractGenerator.ts Outdated Show resolved Hide resolved
@catloversg
Copy link
Contributor Author

I was surprised to see that the number of contracts generated online is fixed at 1. Does that mean that the online issue isn't actually this? If you exploit and change the date while BB is running, does it still hang or does this fix it?

AFAIK, we don't have a problem with the online generation. All reports that I have seen only show the problem of loading a save file. If the player changes the date while Bitburner is running, the game will not hang due to the CCT generation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite loading when date is too far in the past
2 participants