Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344// Known-answer tests for the three PRNGs. The constants below are the canonical// outputs of the original generators; if these pass, the streams match the binary.#include "sc2k/rng.hpp"#include <cstdio>#include <cstdlib>
#include "test_harness.hpp"
int main() { using namespace sc2k;
// MsRand: the famous MSVC srand(1) sequence. { MsRand r(1); const int expect[] = {41, 18467, 6334, 26500, 19169, 15724, 11478, 29358, 26962, 24464}; for (int e : expect) CHECK(r.next() == e); }
// Lcg: ANSI-constants LCG, first word from state 1. { Lcg r(1); CHECK(r.next() == 16838); }
// Lfsr: verified transitions. seed 1 just shifts; seed 0x8000 taps with 0x1BF5. { Lfsr a(0x0001); CHECK(a.step() == 0x02); CHECK(a.state() == 0x0002); CHECK(a.step() == 0x04); CHECK(a.state() == 0x0004); Lfsr b(0x8000); CHECK(b.step() == 0xF5); CHECK(b.state() == 0x1BF5); }
if (failures == 0) { std::printf("rng: all known-answer tests passed\n"); return 0; } std::printf("rng: %d failure(s)\n", failures); return 1;}