Random?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Ethril
Posts: 2677
Joined: Sun Nov 16, 2008 2:59 am
Location: with you in the dark

Re: Random?

Post by Ethril »

Nash wrote:"Well, maybe the ghost was murdered in the dining room, so that's why it appears there a lot".

:P
Oh God, that really WAS Chris's blood! D:

Also, I'd like to see this mansion for myself. :B
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Random?

Post by randi »

I've just changed random number seeding at game startup so that it picks from a larger entropy pool, and I've also switched the algorithm to the Mersenne Twister, which is supposed to produce high-quality psuedo-random numbers. How does that work for you?
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Random?

Post by HotWax »

Interesting. So did the original Doom also seed the RNG on startup or did you add this for better randomness in ZDoom? Is that why you had to add the seed to the demo format then?

I can't remember where I first read it (it was years and years ago), but I'm certain that I read that id specifically chose not to have "true" random numbers in Doom so that demos would play properly every time. I assumed that would require having its own RNG algorythm that could be reset whenever a map/demo was started, keeping everything consistent.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Random?

Post by randi »

Doom didn't seed the RNG. In fact, it didn't have a "real" RNG at all. All it had was a table of numbers that it stepped through one after another whenever it needed to pick a "random" number, and it always started picking numbers from the first entry, so randomness in Doom was very deterministic and consistent from run to run.

BOOM does have a seed, which was initialized to 1993, but I don't remember if it did anything to vary it each time you started the game.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: Random?

Post by HotWax »

randi wrote:Doom didn't seed the RNG. In fact, it didn't have a "real" RNG at all. All it had was a table of numbers that it stepped through one after another whenever it needed to pick a "random" number, and it always started picking numbers from the first entry, so randomness in Doom was very deterministic and consistent from run to run.
Aha, I figured it was something like that. Well, good to know ZDoom is much more random than vanilla Doom. I never understood why id didn't just code it to be random like everything else and store the seed like you're doing. Maybe they wanted to save a few bytes in the demo format? :P

Of course, given that there wasn't any scripting in Doom, they probably didn't consider true randomness all that important -- after all, the monster AI could be 100% set in stone with only the player's actions affecting the decisions and it probably wouldn't hurt the game too much.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Random?

Post by randi »

Speed may have been an issue. Doom was targeted at 386+ hardware, and picking a number out of a table was faster than calculating a new value.
HotWax wrote:Of course, given that there wasn't any scripting in Doom, they probably didn't consider true randomness all that important
Which is probably the case. I remember having some map that picked something random in an open script, but it always picked the same thing, which obviously wasn't very random, so I had to add some randomness to it.
User avatar
LilWhiteMouse
Posts: 2270
Joined: Tue Jul 15, 2003 7:00 pm
Location: Maine, US
Contact:

Re: Random?

Post by LilWhiteMouse »

randi wrote:How does that work for you?
Can't say for certain until I've made sufficient runs, but it does seem better. I ran 10 test runs of Chibi Rebellion and did notice a slight pattern, but if I played in earnest I'm not sure it would appear/be relevant. When my scripts were called within a minute of each other, they sometimes stick to certain numbers, next minute stick to a new number, and so on. Compared to the old behavior though, these results are a vast improvement.

Code: Select all

05-21-34-43-54-62-76-84-90-109
05-23-32-45-51-65-74-81-90-109
05-23-34-44-54-63-70-81-94-109
06-20-36-40-54-63-73-85-94-106
05-20-32-46-55-64-76-85-93-107
05-20-32-41-52-63-74-81-95-105
08-23-31-41-52-63-74-81-95-105
08-25-35-44-51-61-72-84-95-110
07-23-36-45-54-60-71-84-91-109
05-23-33-43-54-62-76-80-94-108
Just so there isn't any confusion, my scripts select 10 maps, one map0x, one map1x, one map2x, and so on. Except for the first and last maps, there are at least six maps in each pool. There's actually 12 maps in the last pool, which is puzzling why it seems to repeat the most. ::shrugs:: I'm more then content however.
Locked

Return to “Editing (Archive)”