Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

TL;DR: rand() loops through a fixed set of values, but unpredictable user input leads to unpredictable sequence of rand() calls (e.g. an animation calling it before or after a sound-effect selector), providing an unpredictable output from rand().


This is the most interesting part to me, and the irony of the random output.

The "random number generator" isn't actually the table, but rather the table <-> the amount of times the function is actually called (aka player input as a source of randomness).

If the game were coded in such a way that there are more deterministic random calls (enemy seeding at beginning of a level, etc) then it would feel less random. If it were coded in a way that there are more non-deterministic random calls (enemy spawning based on table index when a player enters a room) then it would feel more random.

The table is deterministic, but the exact value returned for any given event X is the product of how many random() calling events happened before event X.

Or, in the ideal engineering way: achieve the minimal randomness required for player belief, and use the saved computational overhead on my interesting things (e.g. graphics).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: