summaryrefslogtreecommitdiff
path: root/src/util/include/random.hpp
blob: cd8ab1c6bab6b971932091cc9d4dbb4af95d20ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright 2023 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#pragma once

#include <cstdint>

#include "komihash.h"

namespace util {

class IRandom {
 public:
  virtual ~IRandom() {}

  virtual auto Next() -> std::uint64_t = 0;
  virtual auto RangeInclusive(std::uint64_t lower, std::uint64_t upper)
      -> std::uint64_t = 0;
};

extern IRandom* sRandom;

class Random : public IRandom {
 public:
  Random();

  auto Next() -> std::uint64_t override;
  auto RangeInclusive(std::uint64_t lower, std::uint64_t upper)
      -> std::uint64_t override;

 private:
  std::uint64_t seed1_;
  std::uint64_t seed2_;
};

}  // namespace util