Randalator: For example: Random level generation would mostly produce broken levels with inaccessible rooms or items, impossible geometry, etc..
Indeed. True randomness is useful for say card order when playing solitaire. But anything else, dungeon/world creation is more based on say a maze. The maze will have rules, like you can't have more than 3 walls in any square, and the destination needs to actually be reachable.
To start a random dungeon, you'd start probably with a seed, and then place a couple random located up/down portals.
Afterwards, you can either randomly assign a room to each one where it actually connects.
Or make a path connecting them all in the shortest path, then do a few branching rooms
Or make a number of disconnected rooms, and then connect paths to them (
This one seems like what Castle of the winds and Rogue-likes do).
Finally randomly clutter in empty spots treasure and/or monsters.
For something like Windforge there's weights to items, so the likelyhood of getting something at X, and then it will fill in that plus N number of spots nearby with similar items, like ores diamonds, dirt, rock, etc.
Some games will generate the world/area, and then assign quests or things each NPC should do, then let it run on it's own scenario for 1000 turns or something, so when you enter it doesn't feel like everyone just got out of their T-pose and are all trying to get money from the bank to purchase their morning coffee.
Darvond: Also in computing, there's no such thing as Random. Due to the logical and strictly binary nature, most "random" things are instead "seeded", that is the computer will look at a rapidly scrolling list of numbers and pick what happens based on that specific number it saw.
Seed 52959=You rolled a 7.
less rolling list and more a single number that changes with each iteration.
RNG does something where you take the number+value(
some large prime number), square it, then return the number. At least that's for more basic ones, cryptography can make it more complex, LFSR (
Linear Feedback Shift Register) jumps all over the place and needs little in the way of calculation and is easy to implement
As for how the number is used, typically i just modular divide (
get the remainder) to get within a range i want. Some languages give you a number between 0 and 1, so multiplying against the largest number you want gets a similar but slower result.
And while true randomness is unlikely, just being unable to predict how it is going to act is sufficient. Assuming you need say 100 numbers for generate something, the same seed in a different place in the chain can result in VERY different results.