Programming Pokémon Showdown Damage Calculator

Noticing the calculator will keep random information from previous calcs and pokemon in the portion above the customization menu, #hko chance, moves, etc and they'll stay there until refresh. Seems to be random and I cant replicate it so I only have 1 screenshotted instance of a calc displaying incorrect information vs identical calc displaying correctly after refresh
 

Attachments

Heyo. A Pokemon holding Punching Glove and using a punching move will ignore Fluffy's damage reduction (because the glove turns them into non-contact moves). This doesn't apply to Protective Pads, just Punching Glove.

View attachment 621937

This has been tested on cart as well: https://www.smogon.com/forums/threa...chanics-research.3709545/page-23#post-9434178

The calculator, though, outputs damage for a mon holding Punching Glove and using a punching move as if Fluffy still applied (i.e. the calculator shows half the damage that will actually be done).
Fixed
 
I am sorry if this has been asked before but how do you know how much damage Mirror Coat will do to an opponent?
basically, assuming your opponent used a special move, then the amount of hp you lost from their move, you deal double the amount of hp amount back to them. So for instance, if my Wobbuffet loses 151 HP from my opponent's Dialga's Dragon Pulse, then its Mirror Coat will deal 302 HP in return.
 
The damage calculator checks if it is specifically by Terapagos-Stellar instead of whether the Pokemon's Tera type is Stellar type, and then the damage calculator will then automatically update the type of Tera Starstorm. If you change the forme to "Terapagos-Stellar", then the damage associated with Tera Starstorm will automatically update.

View attachment 621716

I personally think that clicking Tera Stellar should update the forme in the same way it happens with Ogerpon, so I will look into it and come back to you on that.
Implemented
 

Felucia

Robot Empress
is a Battle Simulator Moderator
Suggestion: Only calculate multiscale for the first hit of a calc. So rather than
252+ SpA Rotom-Wash Hidden Power Ice vs. 156 HP / 36 SpD Multiscale Dragonite: 122-144 (33.7 - 39.7%) -- guaranteed 3HKO
it'd say
252+ SpA Rotom-Wash Hidden Power Ice vs. 156 HP / 36 SpD Multiscale Dragonite: 122-144 (33.7 - 39.7%) -- guaranteed 2HKO through Multiscale
 
Hi, I've set up the following matchup in X/Y mode:

Staraptor @ Choice Scarf
Level: 100
Adamant Nature
Ability: Reckless
EVs: 252 Atk / 252 Spe
- Double-Edge
- Brave Bird
- Close Combat
- Thief

vs

Metagross @ Metagrossite
Level: 100
Jolly Nature
Ability: Clear Body
EVs: 252 Atk / 4 Def / 252 Spe
- Meteor Mash
- Zen Headbutt
- Hammer Arm
- Ice Punch

And for some reason, Staraptor's Thief shows as doing slightly more damage than Close Combat - Thief does 110 - 130 against CC's 108-128. Is that correct? They read as doing the same damage when I replace Choice Scarf with Choice Band.
 
Hi, I've set up the following matchup in X/Y mode:
...
And for some reason, Staraptor's Thief shows as doing slightly more damage than Close Combat - Thief does 110 - 130 against CC's 108-128. Is that correct? They read as doing the same damage when I replace Choice Scarf with Choice Band.
This is correct. There's a subtlety in the damage formula where, before multipliers, the base damage (directly proportional to level, move base power, attack stat, inversely proportional to defense stat) has a +2 added to it. This +2 means that doubling move base power is not strictly the same as the doubling from type effectiveness - type effectiveness comes after the +2, base power comes before. The reason Choice Band decreases the difference is that the higher the base damage, the less the +2 does and the more equivalent doubling base power/x2 from type become.
 
Want to remention that Neutralizing Gas doesn't seem to be affecting certain Abilities. Was mentioned in some earlier posts but didn't see a mention of it in reply.

Kingambit against NG
252+ Atk Supreme Overlord 3 allies fainted Kingambit Iron Head vs. 252 HP / 80+ Def Weezing-Galar: 278-330 (83.2 - 98.8%) -- guaranteed 2HKO
View attachment 615101

Kingambit against Levitate
252+ Atk Supreme Overlord 3 allies fainted Kingambit Iron Head vs. 252 HP / 80+ Def Weezing-Galar: 278-330 (83.2 - 98.8%) -- guaranteed 2HKO
View attachment 615102
Fixed
 
Hey guys, I didnt know where this post ahould be.
I would like to know how the chances are calculated to the 2HKO.
I mean, how can you explain this (in bold):
-1 252+ Atk Rayquaza Dragon Ascent vs. 244 HP / 156 Def Tera-Water Ogerpon-Wellspring: 82-97 (44 - 52.1%) -- 14.5% chance to 2HKO
However, if it was at 50% of health:
-1 252+ Atk Rayquaza Dragon Ascent vs. 244 HP / 156 Def Tera-Water Ogerpon-Wellspring: 82-97 (44 - 52.1%) -- 31.3% chance to OHKO
It is just an example, if you can explain or just share the formula.
Thanks
 
For Rayquaza to OHKO from 50%, it needs to get a high roll. For it to 2HKO from 100%, it needs to get two relatively high rolls. Because the move only has a 30% chance to do 50+ damage, averaging 50+ over two rolls is harder than just getting it once.

Pokémon damage rolls have 16 possible outcomes, which is a bit much to illustrate, so here's a simplified example. Suppose Rayquaza attacks, and it only has four damage rolls: 38, 39, 40, and 41. If Ogerpon is at 40 HP, then it's easy to see that Rayquaza has a 50% chance of killing: it has to roll a 40 or a 41. If we double Ogerpon's HP, and look at Rayquaza doing two attacks, we now have 16 possible outcomes: 38+38, 38+39, 38+40, 38+41, 39+38, 39+39, 39+40, 39+41, 40+38, 40+39, 40+40, 40+41, 41+38, 41+39, 41+40, and 41+41. Of those outcomes, only six add up to deal at least 80 damage. 6/16 is 37.5%, less than 50%, because Rayquaza now needs to roll high twice.

Hope that helps, let me know if it was unclear :tyke:
 
It looks like the calc is not correctly giving the Hadron Engine boost to non-grounded pokemon.

Using this battle's turn one as a reference (we have confirmed the stat spreads involved):

0 SpA Zapdos Thunderbolt vs. 0 HP / 4 SpD Ribombee: 157-186 (60.1 - 71.2%) -- guaranteed 2HKO (with Hadron Engine as the ability)
0 SpA Adaptability Zapdos Thunderbolt vs. 0 HP / 4 SpD Ribombee: 210-248 (80.4 - 95%) -- guaranteed 2HKO (the correct boost)
0 SpA Hadron Engine Zapdos Thunderbolt vs. 0 HP / 4 SpD Ribombee in Electric Terrain: 271-319 (103.8 - 122.2%) -- guaranteed OHKO (with Gravity in effect)

The damage roll in the battle was 91%, solidly in the middle of the Adapt and Hadron-but-not-Terrain-boosted damage range.

TL;DR: Hadron Engine should still give the 4/3ers boost to non-Grounded Pokemon in the calc even though they do not get the Terrain boost.
Fixed (sorry for delay)
 
  • Love
Reactions: UT
Noticed that the calc now defaults Maushold's Population Bomb to 3 hits instead of 10 like it used to. Surely 10 isnt the expected value of hits you are going to get but in practice you want to calc for 10 hits. Would it be possible to change it back to 10 hits?
 
I had played PokeRogue recently, and it got me interested in the idea of calculating above level 100. Since the calc doesn't go above 100, I was going to do it by hand, but that requires knowing the stats at the higher levels and a whole other bag of worms. To make it simple, I was going to calc for damage between 252+ SpA Darkrai Dark Pulse vs. 252+ SpD Lugia at levels 50, 100, 150, and 200 to compare and see if the damage is linear and whatnot. The first two calcs were to compare to the showdown calc and see if I was correct, and I was not.

As you can see in the screenshots Darkrai should be doing 84-98 at level 50 based on the calculator, but on my hand calcs (Variables D and E, where E is splitting the formula into two parts to account for rounding), I calc for 86-102. And for the life of me I cannot see the mistake. Does anyone know what's going on here? Is there a math error I made? Is the showdown calc wrong in this one instance? Is the documentation for the damage formula wrong? Because honestly I don't know anymore.

Legend
X = Lugia's Hp calc
Y = Lugia's SpD calc
A = Darkrai's Hp calc
B = Darkrai's SpA calc
D = Damage calc
E = Simplified Damage calc for rounding
r = random slider for damage rolls

Capture.PNGCapture 1.PNGCapture 2.PNG

And yes I tried 33 and 34 in the bottom equation, and neither gets the right answer
 
I had played PokeRogue recently, and it got me interested in the idea of calculating above level 100. Since the calc doesn't go above 100, I was going to do it by hand, but that requires knowing the stats at the higher levels and a whole other bag of worms. To make it simple, I was going to calc for damage between 252+ SpA Darkrai Dark Pulse vs. 252+ SpD Lugia at levels 50, 100, 150, and 200 to compare and see if the damage is linear and whatnot. The first two calcs were to compare to the showdown calc and see if I was correct, and I was not.

As you can see in the screenshots Darkrai should be doing 84-98 at level 50 based on the calculator, but on my hand calcs (Variables D and E, where E is splitting the formula into two parts to account for rounding), I calc for 86-102. And for the life of me I cannot see the mistake. Does anyone know what's going on here? Is there a math error I made? Is the showdown calc wrong in this one instance? Is the documentation for the damage formula wrong? Because honestly I don't know anymore.

Legend
X = Lugia's Hp calc
Y = Lugia's SpD calc
A = Darkrai's Hp calc
B = Darkrai's SpA calc
D = Damage calc
E = Simplified Damage calc for rounding
r = random slider for damage rolls

View attachment 624277View attachment 624278View attachment 624279

And yes I tried 33 and 34 in the bottom equation, and neither gets the right answer
So basically, rounding steps in the damage calculator are strange. I would read the Bulbapedia damage formula article very carefully, especially when it comes to rounding numbers up and down to integers.
 
So basically, rounding steps in the damage calculator are strange. I would read the Bulbapedia damage formula article very carefully, especially when it comes to rounding numbers up and down to integers.
I figured it out and I'm so upset.

From Generation V onward, there are three different types of rounding; a flooring (the same as previous generations), rounding to the nearest integer while rounding down at 0.5, and rounding to the nearest integer while rounding up at 0.5.

This is what it states on the article. And the part that it applies to the formula is when there is ever a decimal as a result of a single step of the damage calculation, you round to the nearest integer (rounding down at 0.5). Which it states here.

Unless otherwise specified, all divisions and multiplications past the initial base damage calculation are rounded to the nearest integer if the result is not an integer (rounding down at 0.5).

Though the wording seems like it's describing the modifiers, it can't be. Otherwise if you were to max roll an attack with STAB that is neutral it would result in a modifier of 1.5, which would then need to round down to 1, effectively negating the STAB altogether.

So when you do this you would end up with the resulting damage number of 33.92 which rounds to 34. Making the original calculation correct.

What showdown seems to do is FLOOR the final result (It's still unclear if showdown floors the decimals in the calculation as it comes out to 33.68 which would round to the same integer that 33.92 would by any method). Any way you slice it, showdown sees the final answer of the calc as 33. But were not done, because I stated in my first reply that 33 doesn't get the correct results either. When you plug 33 in for damage into the modifier equation with a max roll, the final result is 99, but on Showdown it's 98. Looking through the rest of the spread, I noticed all the numbers were even (I'd guess this is common knowledge, but I hadn't noticed until now. I usually just look at percentages).

I thought I had cracked it. Showdown rounds to the nearest even number for its damage results. Then I started checking the rest of the rolls. Immediately, I found another issue. A roll of 0.99 still results in a 98.01 which would round to a 98, but showdown shows the 0.99 roll to be a 96.

This is getting long winded so I'll shorten it as much as I can. I learned that showdown must combine all the modifiers, such as STAB, Type effectiveness, and random rolls and then round down to the nearest decimal (e.g. 2.34 and 2.39 both round down to 2.3) BEFORE multiplying it by the damage calc, then it rounds to the nearest even number.

And this... was the closest I got. For you see, as I checked the rest of the rolls on the table, I noticed that there should be one more roll of 90 and one less of 84. At a roll of 0.9, the damage modifier is exactly 2.7 which multiplies by 33 to equal 89.1 and it rounds up to 90. At rolls of 0.91, 0.92, and 0.93, the modifier is in the 2.7 range and thus they all equal 90. Rolls of 0.89, 0.88, and 0.87 put the modifier at 2.6, which results in an 86 after rounding. However, the roll of 0.87 shows a result of 84 on showdown. What all these numbers mean is that the rolls of 0.87 (3/16) and 0.9 (6/16) are shown to be in a range lower than they should be.
The exact range by these rules should look something like this (84, 84, 86, 86, 86, 90, 90, 90, 90, 92, 92, 92, 96, 96, 96, 98).

The only pattern I can see is that in the showdown range, there are 5 sets of 3 numbers and then a max roll. I have no idea why this is, and I couldn't figure it out without seeing the formula on the calculator myself and I'm no programmer. My best guess is that showdown normalizes the set to show it being more linear in progression, but take that with a grain of salt.

Okay, rant over. If anyone knows why the Showdown calc behaves this way or has any more insight, or an alternate/better explanation than what I found, please share.
 

Users Who Are Viewing This Thread (Users: 1, Guests: 1)

Top