-
Notifications
You must be signed in to change notification settings - Fork 176
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
Make Output Chances Deterministic #2565
Open
ghzdude
wants to merge
45
commits into
GregTechCEu:master
Choose a base branch
from
ghzdude:gh-deterministic-chances
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+616
−200
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ghzdude
force-pushed
the
gh-deterministic-chances
branch
from
September 7, 2024 23:16
c008e07
to
f1275d9
Compare
add constructors
improve toString()
add check for previous recipe make XOR use cache getter method
simplify constructors
try to make outputs appear more random initially
rip rollover
make `passesChance()` defualt for override
move cache, machine tier, recipe tier, and boost function into RecipeContext add CalculatedOutput so that chance logic set amounts for overflowing chances fix XOR logic tests because the behavior of XOR was changed slightly
ghzdude
force-pushed
the
gh-deterministic-chances
branch
from
November 16, 2024 05:21
07c6168
to
2cb3f2a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Changes the chanced output logic to be more deterministic instead of purely relying on pseudo-rng.
Adds the ability to use fractions as a chance.
Implementation Details
Chances are made deterministic by caching failed chances when rolling to add to it on the next roll. A role is considered successful if the chance + cached chance exceeds the entry's max chance. The OR chance logic also has the added behavior of succeeding several times if the chance is many times over the max chance.
Cached chances are stored in ARL as a Object2Int map, and is serialized to NBT. If a chanced entry is rolled for the first time, a random number between
[0,entry.getMaxChance())
is returned, acting as an initial offset. The cache is cleared when a new recipe is found and is different from the previous recipe.added extra methods to RecipeBuilder to interpret a string as a fractional chance, allowing for irrational fractions to be used as chances. the fraction is split into numerator and denominator, and then scaled up to the max chance (10,000) to make adding chance boosts easier.
Outcome
death to rng