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

feat: [closes #383] Random number generator seeding #397

Merged
merged 15 commits into from
Mar 17, 2023

Conversation

jeremyckahn
Copy link
Owner

What this PR does

This PR implements random number generation seeding. The seed state is stored as a URL query parameter rather than the farmhand.state object so that seeded URLs can be shared.

This is a feature designed for speedrunners. With a guaranteed sequence of random numbers, Farmhand's behavior can become completely predictable, thus enabling consistent speedrun experiences.

How this change can be validated

In a Private/Incognito browser session, open the preview URL with an embedded seed query param: https://farmhand-git-feature-383rng-seed-jeremyckahn.vercel.app/?seed=test

Observe that the value of Carrot Seed in the Shop is $21.10. Feel free to test other seed values, this is just a baseline.

Then in another Private/Incognito browser session, open the preview URL without an embedded seed query param: https://farmhand-git-feature-383rng-seed-jeremyckahn.vercel.app/

Observe that the value of Carrot Seed in the Shop is a random value for each new Private/Incognito session.

Additional information

Random seed UI

@jeremyckahn jeremyckahn requested a review from lstebner March 14, 2023 14:21
@vercel
Copy link

vercel bot commented Mar 14, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
farmhand ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 17, 2023 at 2:51AM (UTC)

Copy link
Collaborator

@lstebner lstebner left a comment

Choose a reason for hiding this comment

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

overall i like this approach! just a few questions/comments for you

src/common/services/randomNumber.js Show resolved Hide resolved
src/handlers/ui-events.js Outdated Show resolved Hide resolved
src/react-app-env.d.ts Show resolved Hide resolved
src/utils/isRandomNumberLessThan.js Show resolved Hide resolved
Copy link
Owner Author

@jeremyckahn jeremyckahn left a comment

Choose a reason for hiding this comment

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

Thanks for the helpful review @lstebner! I think we should be set now. It's getting late for me so I'll let this sit and wait to merge and release until tomorrow morning. Feel free to add any comments in the meantime!

src/react-app-env.d.ts Show resolved Hide resolved
src/utils/isRandomNumberLessThan.js Show resolved Hide resolved
src/handlers/ui-events.js Outdated Show resolved Hide resolved
src/common/services/randomNumber.js Show resolved Hide resolved
@jeremyckahn jeremyckahn merged commit 4b1b852 into develop Mar 17, 2023
@jeremyckahn jeremyckahn deleted the feature/383__rng-seed branch March 17, 2023 13:54
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.

2 participants