History

update to ck_random()

Ge Wang committed 3 years ago

Commit 2f2c9671 parent 170b70a7 files · +74 −75Browse files

Showing the changes to src/core/util_math.cpp (1 of 7 files). Show all

Unified · Split

src/core/util_math.cpp+11−12
@@ -68,31 +68,30 @@ double trunc( double a ) · 67 unmodified lines
6868 #endif
6969
7070
71−#ifndef __OLDSCHOOL_RANDOM__
72−
71+//-----------------------------------------------------------------------------
72+#ifndef __OLDSCHOOL_RANDOM__ // not using old school, pre-c++11 compatibility
7373 //-----------------------------------------------------------------------------
7474 // name: ck_random() and ck_srandom()
75−// desc: chuck wrappers for random number generators | 1.4.2.0 (ge)
75+// desc: chuck wrappers for random number generators
76+// 1.5.0.1 (ge) using mt19937 (requires c++11)
7677 //-----------------------------------------------------------------------------
7778 static std::mt19937 g_ck_global_rng;
78−t_CKINT ck_random() { return g_ck_globa_rng() % CK_RANDOM_MAX; }
79+t_CKINT ck_random() { return g_ck_global_rng() % CK_RANDOM_MAX; }
7980 void ck_srandom( unsigned s ) { g_ck_global_rng.seed(s); }
80−
81−
81+//-----------------------------------------------------------------------------
8282 #else // using old school random (pre-c++11)
83−
8483 //-----------------------------------------------------------------------------
8584 // name: ck_random() and ck_srandom()
8685 // desc: chuck wrappers for random number generators | 1.4.2.0 (ge)
8786 //-----------------------------------------------------------------------------
8887 #ifndef __PLATFORM_WIN32__
89−t_CKINT ck_random() { return random(); }
90−void ck_srandom( unsigned s ) { srandom( s ); }
88+ t_CKINT ck_random() { return random(); }
89+ void ck_srandom( unsigned s ) { srandom( s ); }
9190 #else // __WINDOWS_DS__
92−t_CKINT ck_random() { return rand(); }
93−void ck_srandom( unsigned s ) { srand( s ); }
94−
91+ t_CKINT ck_random() { return rand(); }
92+ void ck_srandom( unsigned s ) { srand( s ); }
9593 #endif
94+//-----------------------------------------------------------------------------
9695 #endif // __OLDSCHOOL_RANDOM__
9796
9897

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t