Aeternalis Evolution, a custom-engine persistent evolutionary MMO. This first commit establishes the project skeleton: - Architecture and design docs: project vision, system overview, engineering constitution, roadmap, 19 ADRs, and the simulation, world, network, persistence and infrastructure architectures. - Headless engineering proof: deterministic synthetic particles, component lifecycle, explicit PRNG streams, canonical snapshots and restored execution. - Build and tooling: CMake 3.28+ / Ninja presets, C++23 feature check, clang-format and clang-tidy config, format check script, Windows check script, and a Docker build context. - Tests: unit tests, benchmarks, a snapshot fuzz target and CLI integration wiring. No gameplay, renderer, network service or running deployment yet. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
34 lines
1.0 KiB
C++
34 lines
1.0 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
namespace evo {
|
|
// SplitMix64; explicit unsigned wraparound. Reference and scope: ADR-0007.
|
|
// This algorithm is never a security primitive.
|
|
class Random {
|
|
public:
|
|
explicit constexpr Random(std::uint64_t state) noexcept : state_{state} {}
|
|
[[nodiscard]] constexpr std::uint64_t next() noexcept {
|
|
state_ += 0x9e3779b97f4a7c15ULL;
|
|
auto value = state_;
|
|
value = (value ^ (value >> 30U)) * 0xbf58476d1ce4e5b9ULL;
|
|
value = (value ^ (value >> 27U)) * 0x94d049bb133111ebULL;
|
|
return value ^ (value >> 31U);
|
|
}
|
|
// The 2^64-1 accepted outputs divide equally among three bins.
|
|
[[nodiscard]] constexpr std::uint32_t ternary() noexcept {
|
|
auto value = next();
|
|
while (value == 0) {
|
|
value = next();
|
|
}
|
|
return static_cast<std::uint32_t>(value % 3U);
|
|
}
|
|
[[nodiscard]] constexpr std::uint64_t state() const noexcept {
|
|
return state_;
|
|
}
|
|
|
|
private:
|
|
std::uint64_t state_;
|
|
};
|
|
} // namespace evo
|