Skip to content

change RNG (except shuffle in duel) to std::mt19937#2827

Merged
mercury233 merged 1 commit into
masterfrom
patch-std-mt19937
Jun 14, 2025
Merged

change RNG (except shuffle in duel) to std::mt19937#2827
mercury233 merged 1 commit into
masterfrom
patch-std-mt19937

Conversation

@salix5

@salix5 salix5 commented Jun 7, 2025

Copy link
Copy Markdown
Collaborator

move non-essential part to this PR

@mercury233
@purerosefallen
@Wind2009-Louse
@fallenstardust

@salix5 salix5 requested a review from Copilot June 8, 2025 10:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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));

@salix5

salix5 commented Jun 8, 2025

Copy link
Copy Markdown
Collaborator Author

@mercury233 @purerosefallen
Can we merge this one first?
The shuffle in duel is put in another PR.

@purerosefallen

Copy link
Copy Markdown
Collaborator

Will consider when test builds done

@mercury233

Copy link
Copy Markdown
Collaborator

Will check this later next week

@salix5 salix5 changed the title change RNG except shuffle in duel to std::mt19937 change RNG (except shuffle in duel) to std::mt19937 Jun 14, 2025
@salix5

salix5 commented Jun 14, 2025

Copy link
Copy Markdown
Collaborator Author

@mercury233
Can we merge this one?

@mercury233 mercury233 merged commit 56b65a1 into master Jun 14, 2025
8 checks passed
@mercury233 mercury233 deleted the patch-std-mt19937 branch June 14, 2025 07:26
@salix5 salix5 restored the patch-std-mt19937 branch June 14, 2025 07:42
@salix5 salix5 deleted the patch-std-mt19937 branch June 14, 2025 07:43
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.

4 participants