penguins  1.0.0
Rng Struct Reference
Inheritance diagram for Rng:
[legend]

Detailed Description

A wrapper around random number generators.

We need this to abstract away the different implementations of randomness under different environments:

  1. The TUI and the CLI use the rand function from the standard C library.
  2. The GUI has BetterRng which wraps the standard C++ functions from <random>.
  3. The test suite calls munit_rand_int_range (see https://nemequ.github.io/munit/#prng).

The struct itself provides pointers to the actual functions of randomness implementations, so it works kind of like an interface in OOP terminology.

Definition at line 129 of file utils.h.

Data Fields

int(* random_range )(struct Rng *self, int min, int max)
 Generates and returns a value in the range [min; max) (i.e. from min inclusive to max exclusive). More...
 

Field Documentation

◆ random_range

int(* Rng::random_range) (struct Rng *self, int min, int max)

Generates and returns a value in the range [min; max) (i.e. from min inclusive to max exclusive).

Definition at line 132 of file utils.h.

Referenced by BetterRng::BetterRng(), BotState::bot_compute_move(), BotState::bot_compute_placement(), generate_board_island(), generate_board_random(), and init_stdlib_rng().


The documentation for this struct was generated from the following file: