Instant Game Implementation
Overview
This document builds upon previously explained RNG (Random Number Generation) principles to show how individual game results are produced using random integers and floating-point numbers.
Game-by-Game Breakdown
π² Dice
Goal: Produce a number between 0.00 and 100.00 with two decimal places
Approach:
Generate a random integer between
0
(inclusive) and10001
(exclusive)Divide the result by 100
Pseudocode:
generateDiceResult() {
let randomInteger = generateInteger(10001)
let result = randomInteger / 100
return result
}
π£ Mines
Goal: Reveal gems while avoiding mines
Approach:
Use RNG to randomly assign
numberOfMines
positions on a boardThe rest of the tiles are considered "gems"
Pseudocode:
generateMinesBoard(edgeSize, numberOfMines) {
let totalTiles = edgeSize * edgeSize
let minesPositions = []
while minesPositions.Count < numberOfMines:
let currentPosition = generateInteger(totalTiles)
if currentPosition not in minesPositions:
minesPositions.add(currentPosition)
let board = []
for index in 0 to totalTiles - 1:
if index in minesPositions:
board.add("mine")
else:
board.add("gem")
return board
}
π Limbo
Goal: Generate a multiplier > 1 (user wins if the rolled multiplier exceeds their guess)
Approach:
Generate a random float
Apply a hyperbolic curve to determine payout
Truncate to two decimal places
Formula Explanation:
houseEdge = 2.0 - rtp
(e.g., if RTP is 0.99, house edge is 1.01)multiplier = 1.0 / ((1.0 - randomFloat) * houseEdge)
Pseudocode:
generateLimboMultiplier(rtp) {
let multiplierDecimalPlaces = 2
let randomFloat = generateDouble()
let houseEdge = 2.0 - rtp
let multiplier = 1.0 / ((1.0 - randomFloat) * houseEdge)
let roundedMultiplier = truncate(multiplier, multiplierDecimalPlaces)
return roundedMultiplier
}
π± Keno
Goal: Randomly draw a set of unique numbers from a board (usually 1β40)
Approach:
Randomly select numbers, ensuring they:
Are not zero
Are not duplicates
Pseudocode:
generateKenoDraw(boardSize, drawCount) {
let numbersDrawn = []
while numbersDrawn.Count < drawCount:
let currentDraw = generateInteger(boardSize + 1)
if currentDraw == 0 or currentDraw in numbersDrawn:
continue
numbersDrawn.add(currentDraw)
return numbersDrawn
}