Dungeonator  1.0.0
a dungeon generator library
Functions
util.h File Reference

various utilities used thoughout the code More...

#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>
#include "pcg_basic.h"
#include "direction.h"

Go to the source code of this file.

Functions

void seedDungeonatorRNG ()
 
bool contains (int *arr, size_t start, size_t end, int element)
 
void shuffleDirections (Direction *array, int n)
 
int uniform_distribution (int rangeLow, int rangeHigh)
 

Detailed Description

various utilities used thoughout the code

Function Documentation

◆ contains()

bool contains ( int *  arr,
size_t  start,
size_t  end,
int  element 
)

test if an int array contains an int

time complexity O(n) (obviously)

Parameters
[in]arrthe array to check
[in]startthe start index to check from
[in]endthe end index to check to
[in]elementthe element to check for
Returns
whether the array contains the element

◆ seedDungeonatorRNG()

void seedDungeonatorRNG ( )

seed the prng used by the dungeon generation algorithm with a non-determentistic seed

◆ shuffleDirections()

void shuffleDirections ( Direction array,
int  n 
)

shuffle the array of directions

Parameters
[in,out]arraythe array to shuffle
[in]nthe length of the array

◆ uniform_distribution()

int uniform_distribution ( int  rangeLow,
int  rangeHigh 
)

get a random number in a uniform distribution of [rangeLow, rangeHigh)

Parameters
[in]rangeLowthe lower number in the range
[in]rangeHighthe higher number in the range
Returns
a random int in the range