-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add bevy_entropy plugin and include it in the default set #2504
Conversation
I don't think this is deterministic where there is system ordering ambiguity - afaik I we don't make a promise about execution order in that case However, I hadn't realised that a mutable resource would be deterministic if ordering is well defined - although obviously that does have the cost of making all entropy access serial. One potentially neat thing would be for the rng to be a custom system parameter, which gets a 'system level' rng seed, without blocking the global entropy. We would probably need a pre-run hook which could hold resources for only a short amount of time (alternatively, chained systems could support something similar and those could be used instead) |
Preface: I think that standardizing on a solution here is extremely important. Without it, each crate in the ecosystem will use their own PRNG solution, bloating dependencies and making a unified approach to determinism pretty much impossible.
We can currently use the single-threaded executor when we want drop-in determinism. There's space in the future for more sophisticated parallel executors as well.
Agreed, this would be extremely useful, and worth baking into Bevy as a whole. RNG use will be quite prevalent in some games, and it would be nice to have a non-blocking solution.
I prefer the former solution; I would probably build it using a simple exclusive system that runs at the start of the schedule and initializes the |
The basic idea of how the system chaining would work is that the first system in the chain would only block the resources that it uses. Basically change chaining into dependencies with 'message passing' Also our single threaded executor also doesn't guarantee ordering afaik, it's just a way to run the parallel system graph but only using one thread |
Right... it runs it in topographic order, but that topographic order may vary freely within the constraints between runs. |
I much prefer
Hmm. It would force a dependency on
The doc strings and examples here are quite good so far. You could add module level documentation, but what probably makes more sense is to add a page on RNG as part of chapter 3 of the new book in the bevy-website repo. See https://github.com/bevyengine/rfcs/blob/main/rfcs/23-quick_start_book.md for an overview of the plan there. |
Commented. Will try to clean this up in the next week or so. |
Not sure why the ci job is failing with something related to I'll look into automatically making rngs or entropy per-system if this lands. |
Ah, the same CI issue exists on |
This is now a part of an RFC: bevyengine/rfcs#55 |
And run `rustfmt`.
What are the pros/cons of this versus |
This predates |
Closing in favor of #7871 and/or bevy_rand. I still think this needs to be built into bevy. |
Objective
Solution
Note that I put up a PR previously to add default rngs. While most other engines (godot, unity, etc) provide built-in rngs, this is a lower-level (and more general?) building block we likely want to start with first.
Open items
Entropy
orEntropySource
?get()
? Naming is ok