-
Notifications
You must be signed in to change notification settings - Fork 5.9k
修复随机数某些平台生成重复数字 #74378
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
修复随机数某些平台生成重复数字 #74378
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
|
|
lightbrotherV
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix random num same
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #74378 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 1
Lines ? 3
Branches ? 0
===========================================
Hits ? 3
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
thanks |
|
hi, @lightbrotherV
|
PR Category
Execute Infrastructure
PR Types
Bug fixes
Description
GetRandomId() 函数每次调用时都会重新初始化随机数生成器 (std::random_device 和 std::mt19937_64),这会导致生成的随机数可能重复或不够随机。
std::random_device 被重复初始化:
每次调用函数时都新建 random_device 和 mt19937_64,可能导致种子相似(尤其在某些平台上 random_device 实现不够完善)。
伪随机数引擎未复用:
mt19937_64 的状态在每次函数调用时重置,失去了伪随机序列的长期统计特性