… | |
… | |
77 | x = x * A + B; |
77 | x = x * A + B; |
78 | return x; |
78 | return x; |
79 | } |
79 | } |
80 | }; |
80 | }; |
81 | |
81 | |
82 | typedef lc_rng<3039177861U, 0> borosh_niederreiter_rng; |
82 | typedef lc_rng<3039177861U, 0U> borosh_niederreiter_rng; |
83 | typedef lc_rng<2147001325U, 715136305U> bcpl_rng; |
83 | typedef lc_rng<2147001325U, 715136305U> bcpl_rng; |
|
|
84 | typedef lc_rng< 1664525U, 1U> lavaux_janssens_rng; |
84 | |
85 | |
85 | template<typename T, int N, int k> |
86 | template<typename T, int N, int k> |
86 | struct gfsr_rng |
87 | struct gfsr_rng |
87 | { |
88 | { |
88 | int i; |
89 | int i; |
… | |
… | |
136 | // and likely of higher quality. |
137 | // and likely of higher quality. |
137 | typedef gfsr_rng<uint32_t, 250, 103> r250_rng; |
138 | typedef gfsr_rng<uint32_t, 250, 103> r250_rng; |
138 | typedef gfsr_rng<uint32_t, 521, 168> r521_rng; |
139 | typedef gfsr_rng<uint32_t, 521, 168> r521_rng; |
139 | |
140 | |
140 | // freeciv uses this one, so it's good enough for us :) |
141 | // freeciv uses this one, so it's good enough for us :) |
|
|
142 | // (also known as mitchell moore generator |
141 | typedef gfsr_rng<uint32_t, 55, 24> freeciv_rng; |
143 | typedef gfsr_rng<uint32_t, 55, 24> freeciv_rng; |
142 | |
144 | |
143 | // this one should be high quality, but is slightly slower than tausworthe |
145 | // this one should be high quality, but is slightly slower than tausworthe |
144 | struct r250521_rng |
146 | struct r250521_rng |
145 | { |
147 | { |
… | |
… | |
147 | r521_rng r521; |
149 | r521_rng r521; |
148 | |
150 | |
149 | void seed (uint32_t seed); |
151 | void seed (uint32_t seed); |
150 | uint32_t next (); |
152 | uint32_t next (); |
151 | }; |
153 | }; |
|
|
154 | |
|
|
155 | ///////////////////////////////////////////////////////////////////////////// |
152 | |
156 | |
153 | // this is actually an adaptor that provides different |
157 | // this is actually an adaptor that provides different |
154 | // distributions of random numbers. |
158 | // distributions of random numbers. |
155 | template<class generator> |
159 | template<class generator> |
156 | struct random_number_generator : generator |
160 | struct random_number_generator : generator |