Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
DOEL

A 1 in 5,000,000 occurrence

Recommended Posts

I was reading some interesting info on this website (http://www.doom2.net/single/weaponfaq.html) and it mentions that killing a revenant with 1 SSG blast is a 1 in 5,000,000 occurrence.

 

I was wondering if anyone has seen this before and if there are any demos or recordings where this happens. I didn't even know this was theoretically possible.

Share this post


Link to post

Damn, I had a feeling it was too good to be true. According to my "feel" revenants go down in 2-3 SSG well placed shots.

 

I wonder what the chances of NOT killing a pinky with a direct rockret impact is. I've had that happen a few times but it is pretty rare.

Share this post


Link to post
28 minutes ago, DOEL said:

Damn, I had a feeling it was too good to be true. According to my "feel" revenants go down in 2-3 SSG well placed shots.

 

I wonder what the chances of NOT killing a pinky with a direct rockret impact is. I've had that happen a few times but it is pretty rare.

 

That one is a lot more common. A direct RL hit does 20d8 damage, plus 128 splash, so you have a one in eight chance of doing only 148 damage, just shy of the pinky's 150 HP. 

 

You're going to see it less often because you're probably not rocketing isolated pinkies too often. And in a small group or a horde, even a tiny bit of splash damage will make the others die in one hit. 

Share this post


Link to post
16 minutes ago, ‹rd› said:

plus 128 splash

I think most of the time you can't even do 128 splash damage since the explosion center will be a little bit in front of the Pinky? Just like if you got hit by a Cyber, if you subtract the multiples of 20, usually it's not 128, or at least the last digit won't be correct or something like that.

 

BTW, the day you changed your avatar, I thought I saw your avatar blinked, but it actually blinked ;P

 

 

To the topic:

Vanilla RNG won't make this happen since it eats 20 numbers in a particular order, but none of those group can make out a full 300 damage SSG blast. In the same time, I think you can always kill a Revenant with 2 full SSG blasts (assuming all pellets hit) with vanilla RNG on the other hand.

 

Rare things usually involve something like 2 rockets killing a Arachnotron/Hell Knight. Other than that, it seems either it's too low or too common to be noticed. 

Share this post


Link to post
1 hour ago, SaladBadger said:

There's some immediate problems with that page, like it implying the SSG fires 21 pellets, it only fires 20. To one-shot a revenant would require every single pellet to roll max damage, since the revenant has 300 hp and the SSG caps out at 300 damage. Rolling the same 1/3 chance 20 times is improbable, but not strictly impossible.

 

But wait! Vanilla's simple RNG means you physically cannot roll max damage on every pellet. I'm not sure what the physical max is at the moment, since the wiki has had some problems with the damage calcs before and I'm not sure they've been corrected yet. So ultimately, in most ports people are running and doing demos with, it cannot happen at all. It's maybe possible on ZDoom with its new RNG, but I would be surprised if the entire random stream has a sequence that would enable it.

Why is it that the RNG cannot roll MAX dmg ouput ? I guess is the same for MIN dmg. Care to explain ?

Share this post


Link to post
19 minutes ago, GarrettChan said:

Rare things usually involve something like 2 rockets killing a Arachnotron/Hell Knight. Other than that, it seems either it's too low or too common to be noticed. 

 

I'd definitely be interested in a post or chart of other "rare occurrences", stuff like you mentioned, Arch-Vile killed in 3 SSG shots, etc.

Share this post


Link to post
5 hours ago, Endless said:

Why is it that the RNG cannot roll MAX dmg ouput ? I guess is the same for MIN dmg. Care to explain ?

 

Doom uses a fixed array of values that it cycles through with RNG calls. This is good enough to simulate RNG in a practical sense, but the offshoot is that shots with a large number of calls (like SSG shots or BFG tracers) will be clamped to a narrower range of values, because it's pretty much impossible to pick "just" the high values or low values.

 

Here's a chart for SSG damage in Boom (assuming no intervening calls, but those won't make a big difference):

chart.png

[edit: While recording demos. Boom uses a different RNG otherwise.] 

 

And vanilla: 

 

chart_1.png

 

Credit to Kraflab for the charts. 

 

 

Edited by ‹rd›

Share this post


Link to post
17 minutes ago, ‹rd› said:

assuming no intervening calls, but those won't make a big difference

 

If the graph doesn't follow a normal distribution how can you say this? Obviously the numbers aren't well-distributed. It seems like it could make a significant difference.

Share this post


Link to post
1 hour ago, ‹rd› said:

 

Doom uses a fixed array of values that it cycles through with RNG calls. This is good enough to simulate RNG in a practical sense, but the offshoot is that shots with a large number of calls (like SSG shots or BFG tracers) will be clamped to a narrower range of values, because it's pretty much impossible to pick "just" the high values or low values.

 

Here's a chart for SSG damage in Boom (assuming no intervening calls, but those won't make a big difference):

chart.png

 

And vanilla: 

 

chart_1.png

 

Credit to Kraflab for the charts. 

 

 


Economics of Doom!!!

That would be a good megawad :D

With maybe some political figures as enemies???
Ohh this is getting juicy, mmm!!!

Share this post


Link to post
On 6/24/2020 at 4:03 PM, ‹rd› said:

Credit to Kraflab for the charts.

 

Hmm, I wonder how those Boom charts are generated. I see a much more normal distribution over 10M trials.

 

Do you have the original source by chance?

 

EDIT: Also, I think the odds of a max damage SSG shot are actually 1 in ~3.5 billion.

 

EDIT2: For fun, I played around with Vanilla's randomness too, and I believe the maximum damage is 250 245.

 

image.png.715f499ec4db47b3b185c75b2513797b.png

Edited by JadingTsunami : Add what i think are the true odds, plus vanilla odds. I was missing a call to M_Random, true calc is 245, I believe

Share this post


Link to post
1 hour ago, DOEL said:

 

I'd definitely be interested in a post or chart of other "rare occurrences", stuff like you mentioned, Arch-Vile killed in 3 SSG shots, etc.

 

 

Share this post


Link to post
2 hours ago, Endless said:

Why is it that the RNG cannot roll MAX dmg ouput ? I guess is the same for MIN dmg. Care to explain ?

The simplest answer: The vanilla RNG table is a linear predefined sequence of numbers. Because of the order the SSG collects values in, plus the mix of spread RNG calls (each hitscan fires one at a time, deals damage, then does the next hitscan) and other various random calls for puffs and other effects between each hitscan test, and even the way the RNG table itself is organised, it cannot ever produce an organised sequence of numbers that will produce maximum damage across all hitscan tests. This means that the theoretical maximum damage of the SSG is actually lower than what the math presents itself as in a vacuum, the surrounding simulations cause/effect doesn't allow for it.

 

ZDoom based ports use something called the Mersenne Twister which algorithmically is supposed to do the same thing, but its unpredictable nature and the way all the various random calls are split up makes it so that its average damage calls can actually be quite different from vanilla, and may even be able to produce theoretically higher or lower results.

Edited by Edward850

Share this post


Link to post
1 hour ago, Edward850 said:

The simplest answer: The vanilla RNG table is a linear predefined sequence of numbers. Because of the order the SSG collects values in, plus the mix of spread RNG calls (each hitscan fires one at a time, deals damage, then does the next hitscan) and other various random calls for puffs and other effects between each hitscan test, and even the way the RNG table itself is organised, it cannot ever produce an organised sequence of numbers that will produce maximum damage across all hitscan tests. This means that the theoretical maximum damage of the SSG is actually lower than what the math presents itself as in a vacuum, the surrounding simulations cause/effect doesn't allow for it.

 

ZDoom based ports use something called the Mersenne Twister which algorithmically is supposed to do the same thing, but its unpredictable nature and the way all the various random calls are split up makes it so that its average damage calls can actually be quite different from vanilla, and may even be able to produce theoretically higher results.

I'm at awe at how a simple and old game has such interesting and mathematical way of functioning. I suck at math but I love people that know and understand math. Thanks mate.

Share this post


Link to post

I recently killed a hell knight with just two rockets.  On map06, the first (?) one you encounter of the level, at that outside part thru the red door.  

Would've been sweet, if I hadn't fired a third rocket

Share this post


Link to post
3 hours ago, JadingTsunami said:

Hmm, I wonder how those Boom charts are generated. I see a much more normal distribution over 10M trials.

 

[snip]


If there is a distribution that normal, you might be using independent calls for each pellet. [edit: ah I realize what's going on. The Boom numbers I posted were calculated assuming the player is recording a demo, which changes a lot!]

 

The gist of the method used for those charts: start at one index and move through the table appropriately for all SSG pellets. That gives you one damage value. Repeat for each starting index to get all of them.

 

 

Edited by ‹rd›

Share this post


Link to post

This feels like a Leetcode sliding window or dynamic programming problem. There’s a set of ordered values and you have to find the maximum subsequence essentially. I’m certain I’ve encountered this exact kind of problem.

 

edit: https://leetcode.com/problems/maximum-subarray/description/

 

except this is a lot easier actually because you know how many “dice rolls” you have and no negatives so it’s really just O(n) to loop through the RNG table and sum a subsequence of length X from every starting point. Which I assume was done above.

Edited by insertwackynamehere

Share this post


Link to post
51 minutes ago, ‹rd› said:


If there is a distribution that normal, you might be using independent calls for each pellet. The gist of the method used for those charts: start at one index and move through the table appropriately for all SSG pellets. That gives you one damage value. Repeat for each starting index to get all of them.

 

Hmm, I think there is a flaw though, P_Random is called for each pellet and additional times for the pellet angle and slope. So adjacent indices could never happen.

 

This is what I simulated to get the distribution I showed.

 

  for (i=0; i<20; i++)
    {
      int damage = 5*(P_Random(pr_shotgun)%3+1);
      angle_t angle = player->mo->angle;
      int t = P_Random(pr_shotgun);
      angle += (t - P_Random(pr_shotgun))<<19;
      t = P_Random(pr_shotgun);
      P_LineAttack(player->mo, angle, MISSILERANGE, bulletslope +
                   ((t - P_Random(pr_shotgun))<<5), damage);
    }

 

2 minutes ago, insertwackynamehere said:

This feels like a Leetcode sliding window or dynamic programming problem. There’s a set of ordered values and you have to find the maximum subsequence essentially. I’m certain I’ve encountered this exact kind of problem.

 

Yes, that is exactly right. :)  In fact this is the method I used to find the vanilla max, except accounting for the additional calls to P_Random.

Share this post


Link to post
6 hours ago, JadingTsunami said:

Hmm, I think there is a flaw though, P_Random is called for each pellet and additional times for the pellet angle and slope. So adjacent indices could never happen.

 

Right, I said to move through the table 'appropriately', which is what that would refer to. I'm not exactly sure where you're getting 'adjacent' from; I didn't use the word or refer to doing that in any of my posts. 

Edited by ‹rd›

Share this post


Link to post
17 minutes ago, JadingTsunami said:

This is what I simulated to get the distribution I showed.

I did this before, and I used up another 2 for angle and stuff. Then I think Ling said probably the blood splat will eat another one, so right now I'm still not sure.

 

I emulated the total damage using every 3 from the array (eg: 1, 4, 7, 10 ...), and the max is somewhere around 250 or 255. I think the easiest way is just to test every single case from 0 to 255 with 20 "random" numbers from the list.

Share this post


Link to post
7 minutes ago, ‹rd› said:

 

Right. I said to move through the table 'appropriately', which is that would refer to. I'm not sure where you're getting 'adjacent' from; I didn't use the word or refer to doing that in any of my posts. 

 

 I see. It is my mistake then.

 

This makes sense for vanilla, but for Boom I do still see a normal distribution over long trials like what I showed. I'm not sure how many trials were done for the Boom chart, but it seems that more are necessary to see the true distribution.

Share this post


Link to post
2 minutes ago, JadingTsunami said:

This makes sense for vanilla, but for Boom I do still see a normal distribution over long trials like what I showed. I'm not sure how many trials were done for the Boom chart, but it seems that more are necessary to see the true distribution.

I think at least in Boom compat, it still follows the vanilla chart.

 

https://www.doomworld.com/forum/post/1769504

 

Maybe you can take a look at this one. In the spoiler tags, I did put my code and test one of the case by hand (yeah, stupid ;P).

Share this post


Link to post

Something I've always wondered - I get that Doom's RNG uses calls to m_random.c to approximate picking a random number between 0 and 255. But how does it convert that into, say, damage rolls for each shotgun pellet (which do 5d3 damage)? Does it skip all numbers that aren't 1-3 until it comes across one? Does it look at the last digit (throwing out 0 and 4-9)? Some other way to convert it into a d3 dice roll?

Share this post


Link to post
14 minutes ago, GarrettChan said:

Then I think Ling said probably the blood splat will eat another one, so right now I'm still not sure.

 

Yes, there are other interspersed calls to P_Random() unless you're shooting at the sky. P_SpawnPuff() for wall puffs and P_SpawnBlood() both call P_Random() 3 times. And there's another call to check the enemy's pain chance upon a hit.

 

Boom draws from a separate random index for each random type so it wouldn't hit these issues, fortunately.

Share this post


Link to post
15 minutes ago, Magnusblitz said:

 Some other way to convert it into a d3 dice roll?

 

It uses a modulo operation. You take a number, divide by (one more than) the maximum random number you want to end up with, and use the remainder left over after the division as your random value. You may add a minimum since the modulo operation can give a 0.

 

So, for a d3 dice roll, say you roll 180. 180/3 = 60, remainder is 0. Add 1 since your d3 dice minimum is 1. So you rolled a 1.

 

Another example, say you roll 241. 241/3 = 80 remainder 1. Add 1, so you rolled a 2.

 

And so on in this way. You can convert any fixed integer to a range like this.

Edited by JadingTsunami

Share this post


Link to post

If a player fires the SSG on the exact same frame that, say, a shotgun guy shoots, is the random damage from all the bullets from one attack calculated before the second? There has to be a deterministic order to which they're done obviously, but I don't know how that order is determined.

Share this post


Link to post

Neither function will return until it has completely finished, so the two won't directly interfere with each other's pellets. I believe the player's SSG will always win and go first because player-specific thinking is done before everything else gets a chance to think.

Share this post


Link to post
14 minutes ago, SaladBadger said:

I believe the player's SSG will always win and go first because player-specific thinking is done before everything else gets a chance to think.

You believe correctly. The player's weapon frames are animated first before even the thinker table. And in the order of player numbers so player 1 would shoot first before player 2. Death is absolute so two players firing at the same frame at each other with a shot that would guarantee death will mean the lower player number will get the kill, and the other player's fire command will be completely ignored as they will already be dead by the time P_PlayerThink reaches them.

Edited by Edward850

Share this post


Link to post

I remember reading that it is easier to 1 shot a Spider Mastermind in Zdoom than in Vanilla. Is it because Zdoom uses a more detailed and correct random table of values or something else?

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
×