Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Old-Doomguy

Does a demo file contain all rng rolls?

Recommended Posts

Hey all 

 

Since doom demos isn't a video but rather a keylog, I was wondering how they replicate a session fully. Doom is full of rng, are all these rolls saved in the file as well?

Share this post


Link to post
Posted (edited)

yep, pretty much. but iirc (and i may be wrong about this) it leaves some out tho cuz they're not necessary, and are done by the viewer instead

Share this post


Link to post
Posted (edited)

Anyone feel free to correct me if I'm wrong, but as I understand it Doom's RNG is an array of numbers that is always in the same order upon startup. If you replicate the exact same actions in the same environment, you will get the same results each time. So the demo doesn't need to track this stuff.

Share this post


Link to post
1 minute ago, DisgruntledPorcupine said:

Anyone feel free to correct me if I'm wrong, but as I understand it Doom's RNG is an array of numbers that is always in the same order upon startup. If you replicate the exact same actions in the same environment, you will get the same results each time. So the demo doesn't need to track this stuff.

actually this is probably the correct answer, listen to this guy instead

Share this post


Link to post

Yes, vanilla doom is a static array of numbers that is always the same. The “dice roll” is just the next number in the array. 

Share this post


Link to post
Posted (edited)
unsigned char rndtable[256] = {
    0,   8, 109, 220, 222, 241, 149, 107,  75, 248, 254, 140,  16,  66 ,
    74,  21, 211,  47,  80, 242, 154,  27, 205, 128, 161,  89,  77,  36 ,
    95, 110,  85,  48, 212, 140, 211, 249,  22,  79, 200,  50,  28, 188 ,
    52, 140, 202, 120,  68, 145,  62,  70, 184, 190,  91, 197, 152, 224 ,
    149, 104,  25, 178, 252, 182, 202, 182, 141, 197,   4,  81, 181, 242 ,
    145,  42,  39, 227, 156, 198, 225, 193, 219,  93, 122, 175, 249,   0 ,
    175, 143,  70, 239,  46, 246, 163,  53, 163, 109, 168, 135,   2, 235 ,
    25,  92,  20, 145, 138,  77,  69, 166,  78, 176, 173, 212, 166, 113 ,
    94, 161,  41,  50, 239,  49, 111, 164,  70,  60,   2,  37, 171,  75 ,
    136, 156,  11,  56,  42, 146, 138, 229,  73, 146,  77,  61,  98, 196 ,
    135, 106,  63, 197, 195,  86,  96, 203, 113, 101, 170, 247, 181, 113 ,
    80, 250, 108,   7, 255, 237, 129, 226,  79, 107, 112, 166, 103, 241 ,
    24, 223, 239, 120, 198,  58,  60,  82, 128,   3, 184,  66, 143, 224 ,
    145, 224,  81, 206, 163,  45,  63,  90, 168, 114,  59,  33, 159,  95 ,
    28, 139, 123,  98, 125, 196,  15,  70, 194, 253,  54,  14, 109, 226 ,
    71,  17, 161,  93, 186,  87, 244, 138,  20,  52, 123, 251,  26,  36 ,
    17,  46,  52, 231, 232,  76,  31, 221,  84,  37, 216, 165, 212, 106 ,
    197, 242,  98,  43,  39, 175, 254, 145, 190,  84, 118, 222, 187, 136 ,
    120, 163, 236, 249
};

you can view it the full file here https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/m_random.c

if your interested

Share this post


Link to post
1 hour ago, DisgruntledPorcupine said:

Anyone feel free to correct me if I'm wrong, but as I understand it Doom's RNG is an array of numbers that is always in the same order upon startup. If you replicate the exact same actions in the same environment, you will get the same results each time. So the demo doesn't need to track this stuff.

 

This is correct. And no RNG data is stored in the demos themselves; all games start with the RNG at 0. To quote from the wiki, "The function M_ClearRandom resets both functions' indexes to zero. It is called during initialization of each new game so that demos will be the same each time they are played, and so that multiplayer games are synchronised."

Share this post


Link to post
Posted (edited)

Basically for rng that affects gameplay (I think it's different for some visual things like doomguy looking left and right) there is a list of all rng values that is in what is supposed to be a random order. Any time something needs an rng value it gets the current number from the list and then moves the number to the next value  for the next thing that needs rng. So if you do the same inputs at the exact same time under the same conditions, 100% of the time it will call the same rng number and do the same thing. This is how demos work consistently as long as your using the same settings on your source port.

So the demo file only needs the inputs (and probably some other miscellaneous information that has to do with the starting state) and doesn't need to include the rng values.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×