< Previous | Contents | Next >

Generating Random Numbers

A sense of unpredictability can add excitement to a game. Whether its the sudden change in a computer opponents strategy in an RTS or an alien creature bursting from an arbitrary door in an FPS, players thrive on a certain level of surprise. Generating random numbers is one way to achieve this kind of surprise.


 

Introducing the Die Roller ProgramCalling the rand() FunctionSeeding the Random Number GeneratorCalculating a Number within a Range