浏览代码

Merge pull request #3157 from IvanSavenko/switch_rng

Use minstd_rand instead of mt19937 to avoid save game bloat
Ivan Savenko 1 年之前
父节点
当前提交
63e99a32d7
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      lib/CRandomGenerator.h

+ 5 - 1
lib/CRandomGenerator.h

@@ -14,7 +14,11 @@
 
 VCMI_LIB_NAMESPACE_BEGIN
 
-using TGenerator = std::mt19937;
+/// Generator to use for all randomization in game
+/// minstd_rand is selected due to following reasons:
+/// 1. Its randomization quality is below mt_19937 however this is unlikely to be noticeable in game
+/// 2. It has very low state size, leading to low overhead in size of saved games (due to large number of random generator instances in game)
+using TGenerator = std::minstd_rand;
 using TIntDist = std::uniform_int_distribution<int>;
 using TInt64Dist = std::uniform_int_distribution<int64_t>;
 using TRealDist = std::uniform_real_distribution<double>;