![]() |
#21 | |
Knight
Join Date: Sep 2013
Posts: 526
![]() |
Quote:
|
|
![]() |
![]() |
![]() |
#22 | |
Veteran
Join Date: Jun 2007
Posts: 1,367
![]() |
Quote:
Similar mechanisms exist for Windows. Incidentally @MattB: Even for games, you'd probably want to just use one of the above mechanisms to get a game seed and periodically reset the game seed from there. In fact, you could probably just get all your random numbers from /dev/urandom (or equivalent) since it should be plenty fast enough for any game needs. However, I believe Angband actually relies on having a consistent RNG throughout the level (for loading/saving) and for the town -- or at least it did in the past. I'm not sure if that was changed during 4.0. It doesn't matter much for games, but it's also interesting to note that reseeding is critical when doing fork() for any application which cares about the cryptographic qualities of its RNG. If you don't you're going to get two endless streams of identical numbers from then on. This is partciularly nasty if you're writing a library (e.g. LibreSSL) since you may not be in control of forking. Last edited by AnonymousHero; June 19, 2015 at 06:55. |
|
![]() |
![]() |
![]() |
#23 | |
Veteran
Join Date: Jun 2007
Posts: 1,367
![]() |
Quote:
![]() Sufficient for games (probably), but not anything serious ![]() |
|
![]() |
![]() |
![]() |
#24 | |
Adept
Join Date: Jun 2012
Posts: 242
![]() |
Quote:
|
|
![]() |
![]() |
![]() |
#25 |
Veteran
Join Date: Mar 2013
Location: Berkshire, UK
Posts: 1,153
![]() |
|
![]() |
![]() |
![]() |
#26 | |
Veteran
Join Date: Jun 2007
Posts: 1,367
![]() |
Quote:
![]() (See my other comment.) EDIT: Alright, I'll elaborate a little bit. Time-in-seconds since 1970 only spans... let's see... about 2 billion numbers (until 2038 or so). That's something that can easily be brute-forced these days. To avoid brute force you need something like 2^64 or, even better, 2^128. Computers are well-powerful, but they can't beat exponentials! Last edited by AnonymousHero; June 19, 2015 at 23:38. |
|
![]() |
![]() |
![]() |
#27 | |
Veteran
Join Date: Jun 2007
Posts: 1,367
![]() |
Quote:
![]() EDIT: I should also say... you got the right basic idea in that you want some externally random data to mix into your "predictable" randomness. These days good random number generators are basically based on encryption: You use a small amount of "real" random data (entropy) and use that as a key for an encryption algorithm (in CTR mode, so it's encrypting 0, 1, 2, 3...) and have that algorithm pump out endless streams of data based on that initial truly random seed. This is what /dev/random and /dev/urandom and getentropy() and GetEntropy(), etc. do. Last edited by AnonymousHero; June 19, 2015 at 23:54. |
|
![]() |
![]() |
![]() |
#28 | |
Veteran
Join Date: Mar 2013
Location: Berkshire, UK
Posts: 1,153
![]() |
Quote:
![]() Although it has got me thinking that maybe I am wrong about what this forum is for. I reckon it's either that: i) This forum is in code and it's actually about government-level cryptology and everyone, except me, is in on it. or, more likely: ii) We are all part of the dreaded RNG. In some kind of Arthur Dent way, we (the forum) exist solely to blindly churn out the very Random Numbers that we battle against daily. Every character of text that we input is converted into hexadecimal and forms, at the next release, the 'random' number string that is used to obliterate our @'s. Meanwhile Nick is laughing maniacally in some Magrathean lair in Australia... |
|
![]() |
![]() |
![]() |
#29 |
Prophet
Join Date: Dec 2009
Posts: 8,941
![]() |
There's two main uses for randomness: security and videogames. In security, if someone can figure out the random number(s) you used, then they can pretty quickly break your encryption, rendering it useless. Having "strong" randomness is thus vitally important. In videogames, it matters less -- the main thing you want is for the player to not notice that sequences are repeating. Basing your randomness off of hard-to-predict stuff like "milliseconds since 1970-01-01 00:00:00" or "milliseconds between program start and player's first input" is generally good enough. Sure, the player could hypothetically manipulate the game by adjusting their system clock or via very carefully-timed inputs, but practically speaking nobody cares.
Unless of course your game has online leaderboards and is popular. ![]() |
![]() |
![]() |
![]() |
#30 | |
Veteran
Join Date: Jun 2007
Posts: 1,367
![]() |
Quote:
Sometimes us programmer types do diverge a little bit off-topic ![]() |
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
kill yourself with mass banishment? | Tibarius | Vanilla | 20 | September 8, 2015 17:12 |
YASD: My best ever Mage just took himself out with a ?Mass Banishment. D'oh! | Goldbug | Vanilla | 10 | May 31, 2013 06:35 |
[3.2] Banishment preserves item on failure | PowerWyrm | Vanilla | 4 | April 22, 2011 22:11 |
Make all artifacts "special" artifacts | Derakon | Development | 14 | March 16, 2011 09:37 |
Is there any way to know what Artifacts I had? | Aldous | Vanilla | 2 | May 24, 2007 05:50 |