| 12345678910111213141516171819202122232425262728293031323334 |
- //
- // random_impl.h
- // pokemon
- //
- // Created by Sam Jaffe on 12/9/17.
- //
- #pragma once
- #include <random/distribution.h>
- #include <random/forwards.h>
- #define IMPLEMENT_DEVICE(X) X(size_t) X(double) X(int32_t) X(uint32_t)
- #define TRIVIAL_RANDOM_DEVICE(T) \
- virtual T apply(Distribution<T> const & dist) { return dist(*this); }
- namespace engine::random {
- class Device {
- public:
- using result_type = uint32_t;
- constexpr static result_type min() { return 0; }
- constexpr static result_type max() { return ~0u; }
- virtual ~Device() = default;
- virtual result_type operator()() = 0;
- private:
- friend class Random;
- IMPLEMENT_DEVICE(TRIVIAL_RANDOM_DEVICE)
- };
- }
- #undef TRIVIAL_RANDOM_DEVICE
|