The importance of REAL random results

I was wondering if functions in various languages used to return random values, such as AS2 Math.random() or Php rand() are returning real random values or just a sequence of numbers someone can predict.

So I asked the question to someone that is facing this problem for a long time: Matt from CasinoInLinea.

That’s what he said:

Random results are very important in many computer applications. From online casino games, through video arcades, image processing to data security & encryption software and many other types of applications.

Since computers are 100% predictable: The same actions, performed at a specific order, will always lead to the same results. This means that generating true random numbers is not an easy task. For a function to produce a random number, one of the variables must have a different value every time.

A series of numbers is truly random if it completely unpredictable. In other words, if we have absolutely no way of knowing what the next number is in a series of N numbers, then the series is completely random. On the other hand, if we can determine the next number according to a specific formula, (i.e. Fibonacci, a linear or parabolic function etc), then the series is a function, and is not random at all. As odd as it may seem, computer functions also have interim statuses. A function can be highly random, (i.e. it’s difficult BUT POSSIBLE to predict the next number). It all depends on the capability of the RNG (random Number Generator) algorithm.

Applications like online casino software and security related programs (i.e. password generators, data encryption and more) demand the highest randomness possible. Imagine a roulette table in which a player can predict where the ball falls next, or a password generating software that generates predictable “random” passwords. Both scenarios present a major security breach for the software operators.

So how do random functions produce random numbers? Here are a few common ways:

The computer’s clock
That’s the easiest, cheapest and least secure method. The computer clock offers an ever changing value that always increases with time. Therefore, it is possible to integrate the absolute time value into the random function to produce random results. (The time value is a 2 * 16 bit, double word binary value) that contains years, months, days, hours, minutes & seconds).

Random keyboard or mouse sequence
Some applications (e.g. client-based password generators) resort to a more creative way of producing a random value. They ask the user to provide a sequence of keyboard strokes or a random mouse curosr movement over a specific screen area (or a combination of both). The keystrokes and/or mouse movements are then compiled to a series of values, which are then compiled to a single, random number. This method is excellent at giving the user a distinct sense of control. Its major drawback is that it cannot be used in automated processes (e.g. command line batch executions).

Hardware-based RNG
For applications where randomness is crucial, such as online casino software or encryption software, RNG extension cards can be installed on server machines. These offer faster, more secure random numbers, which are virtually inpredictable. When randomness is of outmost importance, Hardware based is the best solution, although the most expensive one.

Having said all that, when you develop your next computer game, be it browser or client based, you should not worry too much about random numbers – feel free to use your development environment’s native random functions (which probably use the computer’s clock). The gaming experience is unlikely to be affected by it.

If you’re still serious about random numbers, and demand nothing but the best, this website provides more in-depth information about using random number genreators.

Get the most popular Phaser 3 book

Through 202 pages, 32 source code examples and an Android Studio project you will learn how to build cross platform HTML5 games and create a complete game along the way.

Get the book

// 1+2=3
// 100 rounds
// 10000000
// 2 Cars
// 2048
// A Blocky Christmas
// A Jumping Block
// A Life of Logic
// Angry Birds
// Angry Birds Space
// Artillery
// Astro-PANIC!
// Avoider
// Back to Square One
// Ball Game
// Ball vs Ball
// Ball: Revamped
// Balloon Invasion
// BallPusher
// Ballz
// Bar Balance
// Bejeweled
// Biggification
// Block it
// Blockage
// Bloons
// Boids
// Bombuzal
// Boom Dots
// Bouncing Ball
// Bouncing Ball 2
// Bouncy Light
// BoxHead
// Breakout
// Bricks
// Bubble Chaos
// Bubbles 2
// Card Game
// Castle Ramble
// Chronotron
// Circle Chain
// Circle Path
// Circle Race
// Circular endless runner
// Cirplosion
// CLOCKS - The Game
// Color Hit
// Color Jump
// ColorFill
// Columns
// Concentration
// Crossy Road
// Crush the Castle
// Cube Jump
// CubesOut
// Dash N Blast
// Dashy Panda
// Deflection
// Diamond Digger Saga
// Don't touch the spikes
// Dots
// Down The Mountain
// Drag and Match
// Draw Game
// Drop Wizard
// DROP'd
// Dudeski
// Dungeon Raid
// Educational Game
// Elasticity
// Endless Runner
// Erase Box
// Eskiv
// Farm Heroes Saga
// Filler
// Flappy Bird
// Fling
// Flipping Legend
// Floaty Light
// Fuse Ballz
// GearTaker
// Gem Sweeper
// Globe
// Goat Rider
// Gold Miner
// Grindstone
// GuessNext
// Helicopter
// Hero Emblems
// Hero Slide
// Hexagonal Tiles
// HookPod
// Hop Hop Hop Underwater
// Horizontal Endless Runner
// Hundreds
// Hungry Hero
// Hurry it's Christmas
// InkTd
// Iromeku
// Jet Set Willy
// Jigsaw Game
// Knife Hit
// Knightfall
// Legends of Runeterra
// Lep's World
// Line Rider
// Lumines
// Magick
// MagOrMin
// Mass Attack
// Math Game
// Maze
// Meeblings
// Memdot
// Metro Siberia Underground
// Mike Dangers
// Mikey Hooks
// Nano War
// Nodes
// o:anquan
// One Button Game
// One Tap RPG
// Ononmin
// Pacco
// Perfect Square!
// Perfectionism
// Phyballs
// Pixel Purge
// PixelField
// Planet Revenge
// Plants Vs Zombies
// Platform
// Platform game
// Plus+Plus
// Pocket Snap
// Poker
// Pool
// Pop the Lock
// Pop to Save
// Poux
// Pudi
// Pumpkin Story
// Puppet Bird
// Pyramids of Ra
// qomp
// Quick Switch
// Racing
// Radical
// Rebuild Chile
// Renju
// Rise Above
// Risky Road
// Roguelike
// Roly Poly
// Run Around
// Rush Hour
// SameGame
// SamePhysics
// Save the Totem
// Security
// Serious Scramblers
// Shrink it
// Sling
// Slingy
// Snowflakes
// Sokoban
// Space Checkers
// Space is Key
// Spellfall
// Spinny Gun
// Splitter
// Spring Ninja
// Sproing
// Stabilize!
// Stack
// Stairs
// Stick Hero
// String Avoider
// Stringy
// Sudoku
// Super Mario Bros
// Surfingers
// Survival Horror
// Talesworth Adventure
// Tetris
// The Impossible Line
// The Moops - Combos of Joy
// The Next Arrow
// Threes
// Tic Tac Toe
// Timberman
// Tiny Wings
// Tipsy Tower
// Toony
// Totem Destroyer
// Tower Defense
// Trick Shot
// Tunnelball
// Turn
// Turnellio
// TwinSpin
// vvvvvv
// Warp Shift
// Way of an Idea
// Whack a Creep
// Wheel of Fortune
// Where's my Water
// Wish Upon a Star
// Word Game
// Wordle
// Worms
// Yanga
// Yeah Bunny
// Zhed
// zNumbers