very simple von neumann middle-square prng. can't use rand() in -qatest mode because its implementation varies across platforms which makes testing for consistency in the important parts of this program difficult.
| 227 | // mode because its implementation varies across platforms which makes testing |
| 228 | // for consistency in the important parts of this program difficult. |
| 229 | float myrand(void) |
| 230 | { |
| 231 | static int seed = 72191; |
| 232 | char sq[22]; |
| 233 | |
| 234 | if (ref_file) { |
| 235 | seed *= seed; |
| 236 | sprintf(sq, "%010d", seed); |
| 237 | // pull the middle 5 digits out of sq |
| 238 | sq[8] = 0; |
| 239 | seed = atoi(&sq[3]); |
| 240 | |
| 241 | return seed / 99999.f; |
| 242 | } |
| 243 | else { |
| 244 | return rand() / (float)RAND_MAX; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | void initParticles(cData *p, int dx, int dy) |
| 249 | { |