change RNG (except shuffle in duel) to std::mt19937#2827
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request updates the random number generation across several modules by replacing the custom mtrandom library with the standard C++ std::mt19937 and associated distributions.
- Update header includes to in multiple files.
- Replace custom RNG functions with std::uniform_int_distribution, std::uniform_real_distribution, and std::shuffle.
- Update seeding logic for RNG objects using std::random_device and seed sequences.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| gframe/sound_manager.h | Updated include and type for RNG object |
| gframe/sound_manager.cpp | Replaced RNG calls with std::mt19937 and changed RNG seeding |
| gframe/replay_mode.cpp | Updated include from mtrandom to |
| gframe/duelclient.h | Updated include and type for RNG object with added real_dist |
| gframe/duelclient.cpp | Changed RNG seed and replaced custom RNG functions with standard alternatives |
| gframe/deck_con.h | Updated include and type for RNG object |
| gframe/deck_con.cpp | Updated deck shuffling and RNG seeding logic |
| gframe/client_field.h | Updated include and type for RNG object |
| gframe/client_field.cpp | Updated RNG seeding and shuffling logic |
Comments suppressed due to low confidence (2)
gframe/duelclient.cpp:2264
- [nitpick] Consider explicitly initializing 'real_dist' with a defined range (e.g. [0, 1)) to clarify its intended behavior for position calculation.
(*cit)->dPos = irr::core::vector3df(real_dist(rnd) * 0.4f - 0.2f, 0, 0);
gframe/deck_con.cpp:91
- [nitpick] Since the RNG seeding strategy has been updated elsewhere, consider removing any commented-out legacy seeding code to improve maintainability.
rnd.reset((uint_fast32_t)std::time(nullptr));
Collaborator
Author
|
@mercury233 @purerosefallen |
Collaborator
|
Will consider when test builds done |
Collaborator
|
Will check this later next week |
purerosefallen
approved these changes
Jun 8, 2025
Collaborator
Author
|
@mercury233 |
This file contains hidden or 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
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.
move non-essential part to this PR
@mercury233
@purerosefallen
@Wind2009-Louse
@fallenstardust