Slot Engine is in Beta - Expect bugs!
Slot EngineSlot Engine

RNG Service

Service for seeded random number generation.


Introduction

The RNG service is connected to the underlying program. If you ever need a random outcome in your game implementation, use this seeded RNG service for reproducible results.

Methods

weightedRandom()

MethodType
ctx.services.rng.weightedRandom()(weights) => string

Parameters

ParameterType
weightsRecord<string, number>

Weighted draw of key from a mapping of keys to weights.

randomItem()

MethodType
ctx.services.rng.randomItem()(array) => T

Parameters

ParameterType
arrayArray<T>

Gets a random item from an array.

shuffle()

MethodType
ctx.services.rng.shuffle()(array) => Array

Parameters

ParameterType
arrayArray

Shuffles an array.

randomFloat()

MethodType
ctx.services.rng.randomFloat()(low, high) => number

Parameters

ParameterType
lownumber
highnumber

Gets a random float between two numbers.

Use of AI on this page: All texts were initially written by hand and many were later revised by AI for improved flow. All AI generated revisions were carefully reviewed and edited as needed.

On this page