Utility

A namespace that provides miscellaneous utility functions.

Project

DatabaseCore

Include

Utility.h

Summary
A namespace that provides miscellaneous utility functions.
Provides a (psuedo)random number between 0 and n-1.
Encodes a tile/corner selection into one integer value.
Decodes a single tile/corner selection into separate tile and corner values.

Functions

randNum

wxInt32 MODEL_EXPORT_SPEC randNum(const wxInt32 n)

Provides a (psuedo)random number between 0 and n-1.  The number is guaranteed to be uniformly distributed and uses the Mersenne Twister algorithm to produce its results.

Parameters

nThe upper bound of the (pseudo)random number generated.

Returns

A (pseudo)random number between 0 and n-1.

encodeSel

wxInt32 MODEL_EXPORT_SPEC encodeSel(const wxInt32 tile,
const wxInt32 side)

Encodes a tile/corner selection into one integer value.

Parameters

tileThe tile index.
sideThe side/corner index.

Returns

A single integer value representing the tile/corner combination.

decodeSel

std::pair<wxInt32, wxInt32> MODEL_EXPORT_SPEC decodeSel(const wxInt32 sel)

Decodes a single tile/corner selection into separate tile and corner values.

Parameters

selThe combined tile/corner value.

Returns

A std::pair of the separate tile and corner.  The first value in the pair is the tile, the second value is the corner.

wxInt32 MODEL_EXPORT_SPEC randNum(const wxInt32 n)
Provides a (psuedo)random number between 0 and n-1.
wxInt32 MODEL_EXPORT_SPEC encodeSel(const wxInt32 tile,
const wxInt32 side)
Encodes a tile/corner selection into one integer value.
std::pair<wxInt32, wxInt32> MODEL_EXPORT_SPEC decodeSel(const wxInt32 sel)
Decodes a single tile/corner selection into separate tile and corner values.
DatabaseCore provides a set of commonly used Singletons and namespaces that handle important, but mundane aspects of game management, such as available player colors, configuration options, image maniplulation, file paths, and playing sounds.