Slot Engine is in Beta - Stable, but may contain minor 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: Some texts were improved with or written by AI.

On this page