Programming Pokémon Showdown Damage Calculator

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Posted this the other day but it still seems to be broken.

I think the "doubles" button is bugged for max moves. All other things equal, if you toggle the singles/doubles button and look at the damage for a max move (which of course is single target), the damage changes. I don't understand how this is possible.
Will look Into. You should not be waiting long fwiw
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Posted this the other day but it still seems to be broken.

I think the "doubles" button is bugged for max moves. All other things equal, if you toggle the singles/doubles button and look at the damage for a max move (which of course is single target), the damage changes. I don't understand how this is possible.
fixed
 
Something might be wrong with Dauntless Shield, doesn't seem to be applying Defense buff in Damage Calc

+3 252 Atk Zacian-Crowned Close Combat vs. +1 252 HP / 180+ Def Zamazenta-Crowned: 464-546 (119.5 - 140.7%) -- guaranteed OHKO
Possible damage amounts: (464, 468, 474, 480, 484, 490, 496, 502, 506, 512, 518, 524, 528, 534, 540, 546)

This is with Dauntless Shield

+3 252 Atk Zacian-Crowned Close Combat vs. +1 252 HP / 180+ Def Zamazenta-Crowned: 308-364 (79.3 - 93.8%) -- guaranteed 2HKO

This is without Dauntless Shield, but +1 Defense
 
I noticed there was a "switching out" button, presumably just for Pursuit. However, there are a few things that change damage when the target is switching in, like Fishious Rend, Bolt Beak, Stakeout, and Gen 4 Payback. I think there should either also be a "switching in" button, or just have a single "switching" button that automatically applies switching out or in based on context.
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Is there any chance Silvally can take itemless damage from Knock Off without having to manually remove the item? This interaction is possible to come up in NU battles currently and the damage it takes in the calc is as if it has an item equipped when the item is not knockable, so damage is as if it is itemless.
Do you just mean Silvally with a memory item?
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Yes, for example:


252 Atk Mold Breaker Sawk Knock Off (97.5 BP) vs. 0 HP / 0 Def Silvally-Dark: 53-63 (16 - 19%) -- possible 6HKO

This says 16-19%, but that is the damage it would take with 97.5 BP (as the calc indicates). A player could notice this and simply adjust the calc accordingly, but if the default where to be itemless damage, that would save that step and avoid possible confusion
When I test silvally with a memory item it is getting the same damage result as silvally with no item? Which is what it should be doing when looking at the code
 

Finchinator

-OUTL
is a Tournament Directoris a Top Social Media Contributoris a Community Leaderis a Community Contributoris a Smogon Discord Contributoris a Top Tiering Contributoris a Contributor to Smogonis a Top Smogon Media Contributoris a Super Moderator Alumnusis a Battle Simulator Moderator Alumnusis a Past WCoP Championis the defending OU Circuit Championis a Two-Time Former Old Generation Tournament Circuit Champion
OU Leader
When I test silvally with a memory item it is getting the same damage result as silvally with no item? Which is what it should be doing when looking at the code
https://replay.pokemonshowdown.com/smogtours-gen8nu-503196

Maybe it's impossible to fix in the calculator then? What I am trying to say is that Silvally forms with the memory equipped are always taking itemless damage as it is impossible to knock them, but the calc defaults to normal, item equipped damage. This replay shows it taking 12%, but this is impossible for item equipped damage and the item cannot be removed from Silvally.

They're both my teams being used, so I know for a fact the 12% damage is only accurate if itemless damage is being done:

252 Atk Mold Breaker Sawk Knock Off (97.5 BP) vs. 0 HP / 0 Def Silvally-Dark: 53-63 (16 - 19%) -- possible 6HKO
252 Atk Mold Breaker Sawk Knock Off vs. 0 HP / 0 Def Silvally-Dark: 36-43 (10.8 - 12.9%) -- possible 8HKO
 

MAMP

MAMP!
Hi, currently Photon Geyser is bugged if the user's attack is higher than their special attack, it will calculate damage using the user's attack and the foe's special defense. I've been needing to manually change it to physical. Here's a screenshot:
1590385441871.png
 

pre

pkmn.cc
Can we review the levels of Pokémon as they appear in rands and in calc? I just lost a battle because I selected a move based on this:

+3 Lvl 84 84 Atk Lycanroc Close Combat vs. Lvl 80 84 HP / 84 Def Noctowl: 342-403 (117.5 - 138.4%) -- guaranteed OHKO

But in rands Noctowl is level 88 not level 80, it lived on 1% defeated me (my last Pokémon was itself sitting on 1%). EDIT: Just to be clear: this was rands singles. I know for dubs the levels are not configured and I always remember to change them manually.
I just deployed an update which should have the current levels, however:

Random Battle formats change implementations very often and the calc will never be a source of truth. If we're lucky we get notified when a change goes in and is hotpatched and we can get updated within a few hours, but at its core this is never going to be exact. You should not blindly trust the levels (or moves etc) in the calc, they were only correct at one point and may have been changed. The description helpfully includes the levels in the output so you can verify that the levels are what they say they are, it is merely a convenience, you should still expect to have to change the levels if the Random Battles implementation changes.

Random Doubles levels are a whole other can of worms and pretty much fundamentally will not work with the calc.
 
If a Pokemon's type is manually changed from what it usually is, could the calc make a note of it?

0 SpA Choice Specs Sheer Force Mewtwo Flamethrower vs. 0 HP / 0 SpD Assault Vest Dry Skin Mew: 153-180 (44.8 - 52.7%) -- 25.8% chance to 2HKO

0 SpA Choice Specs Sheer Force Psychic Fire Mewtwo Flamethrower vs. 0 HP / 0 SpD Assault Vest Dry Skin Dragon Mew: 114-135 (33.4 - 39.5%) -- guaranteed 3HKO

This is mostly relevant for defensive Protean/Libero calcs, as well as generic strength comparisons where the usual target is a typeless Mew or something, though Soak (and Magic Powder lol) is also a situation where it could be useful.

On the topic of types, could there also be toggles for Forest's Curse and Trick-or-Treat? They're almost exclusively useful for stacking weaknesses to get crazy calcs, but hey.
 

pre

pkmn.cc
Idk if this has been suggested, but would love to see calcs for random battles added in. Just each mon with its rand bats level and 84 evs in every slot, no items or moves.

This would be more of a convenience thing than anytting for those people who tryhard in rand bats
This already exists. Look for the selector in the top right.
 
I was playing with the calc a bit and I found that multi-hit move KO chances are calculated incorrectly.

1591783486692.png

^The original intention was seeing the chances that one of dragapult's subs can take 4 shuriken hits from specs greninja. However, 22.7-27.7% doesn't seem to match 87.5% chance given by the calc. I did some math and found that the chance is actually ~63.65% (assuming equal probability of each outcome).

1591783876328.png

^Ironically, a simplified calculation of 62.5% is closer to the actual answer than 87.5%

1591782948889.png

1591782994048.png
^That doesn't make much sense considering the mean damage of 4 shuriken hits is 80.25, with 81 and 82 both being above the mean.

1591783231298.png
^I made dragapult fire/ghost in the above case.

1591784166567.png

^I tweaked a lot of inputs to get the damage to be the same but rock blast behaves the same way. It seems that most if not all multi-hit moves, such as dragon darts and twineedle (which only cap at two) have the same issue. However, it appears that the parental bond ability calculates KO chances correctly.

1591783664729.png

^it's easy to see that the actual chance is 1/(16^4), which is a lot far off from 6.3% chance.

1591782603738.png


1591784289763.png


1591784331594.png

1591784388694.png

1591784442947.png

1591784921617.png

1591784796969.png
^Multi-hit moves seem to be using parts of the KO formula for gens 3-8 (with 16 unique damage amounts) instead of gens 1-2 (39 unique damage amounts).
 

Attachments

According the showdown damage calculator a lvl 50 Rash G-Darmanitan w/ 92 SpA EVs should OHKO a lvl 50 Dracovish with EV's invested in Atk/Spe apart from 4 EVs. It didn't. Can confirm that it only dealt about ~2/3...3/4. The Dracovish was not holding an Assault Vest (I tested this on two Dracovish. I don't know the nature of the first one, but I'm assuming a competitive nature, and the second was Gentle). Does anyone know why? Looks like it could be a bug in the damage calculator?
I am very confused as to how you came across this (why were you using a mixed Darmanitan?!) but I found out what's wrong, and it is a calculator problem (hence why I'm replying here and not the mechanics research thread). Gorilla Tactics is boosting special attacks on the calculator when it shouldn't.


92+ SpA Gorilla Tactics Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 168-196 (101.8 - 118.7%) -- guaranteed OHKO

92+ SpA Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 108-132 (65.4 - 80%) -- guaranteed 2HKO
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
I am very confused as to how you came across this (why were you using a mixed Darmanitan?!) but I found out what's wrong, and it is a calculator problem (hence why I'm replying here and not the mechanics research thread). Gorilla Tactics is boosting special attacks on the calculator when it shouldn't.


92+ SpA Gorilla Tactics Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 168-196 (101.8 - 118.7%) -- guaranteed OHKO

92+ SpA Darmanitan-Galar Freeze-Dry vs. 0 HP / 0 SpD Dracovish: 108-132 (65.4 - 80%) -- guaranteed 2HKO
According the showdown damage calculator a lvl 50 Rash G-Darmanitan w/ 92 SpA EVs should OHKO a lvl 50 Dracovish with EV's invested in Atk/Spe apart from 4 EVs. It didn't. Can confirm that it only dealt about ~2/3...3/4. The Dracovish was not holding an Assault Vest (I tested this on two Dracovish. I don't know the nature of the first one, but I'm assuming a competitive nature, and the second was Gentle). Does anyone know why? Looks like it could be a bug in the damage calculator?

Aah, great, thanks! (He had great surprise value against the opponent, and he only would have two jobs in the team basically, which he could've still performed after some SpA investment. I know his SpA is useless. Now I need to rethink a bit obviously.)
Great timing on the reply, I was just about to move the post to here, too.
So currently, if I set SpA to -1 stage, I should get the correct result?
Or change the ability to something else when calcing for Freeze Dry. I used Gooey in the calc I posted just because it's right above Gorilla Tactics in the list. I don't know enough about Pokemon's order of operations to know if -1 will provide exactly the same results.
Fixed thank you :)
 

pre

pkmn.cc
I added a speed column to my local copy turskain's fork for the in game challenges.
Please talk to 'turskain'. The repo you link appears to be using code for about 3 years ago, the supported way to integrate the official damage calculator code into your application is with the @smogon/calc NPM package.
 
Last edited:

pre

pkmn.cc
Keldeo doesn't appear in the rands calc. This is probably because it's Keldeo-Resolute, not Keldeo, which has sets in random battles. Also, Darmanitan-Galar should have two sets, one for its zen form and one for the normal form (this matters because if it gets Zen Mode it's level 80, not level 72).
Keldeo resolute isnt in randbats calc, ty in advance
Sirfetch'd is not in the randbats calc lol
Done. These are all annoying edge cases :)

Can we add eiscue-noice to calc, or things like minior forms
** or in randbats calc sorry
Eiscue-Noice has always been selectable in Random Battle mode, please use the Forme selector

Screen Shot 2020-06-14 at 20.52.03.png


AFAICT, Minior is not supported in S/S random battles, though you can change Minior's forme to Minior-Meteor in S/M in exactly the same way.
 

pre

pkmn.cc
think the calculator for adv mistakenly applies lefties before giving the odds for a one hit
the move here should OHKO for all rolls over 341
Hey, there appears to be a bug with the reporting of % chances to OHKO alongside Leftovers. I got this calc which is very obviously wrong:
It says 0% chance to OHKO when the percentage for the max roll is 105%.
This was in fact a regression introduced by the change Hematite suspected. The EOT "damage" actually mixes damage AND recovery into a single value (which is especially bad because order matters wrt eg. leftovers vs. sandstorm), and naively adding it gives all these fun KO chance bugs you've all detected. I've backed out the change, which means unfortunately EOT residuals will not be accounted for (which was what the change was originally intended to fix) for OHKO chance calculation (though we at least wont say "after hail damage" when we're not accounting for hail damage, and we will still show residual damages for multi-turn KOs). Unfortunately, the existing calc's handling of KO chance is woefully inadequate to the point where its not really worth saving, but in the new calculator I'm writing this is handled much more comprehensively.

I was playing with the calc a bit and I found that multi-hit move KO chances are calculated incorrectly.
Could you possibly check again now that the KO chance change was reverted? Thanks.
 

pre

pkmn.cc
I think the way you implemented this is great. Just one thing though,there appears to be a bug involving hidden powers that reduce HP DVs in GSC where the HP DV doesn't get reduced (or in fact gets increased back to 15). For example if I choose Hidden Power Fighting, which should reduce my HP DV to 3 upon selection, it stays as 15.
Oops, I cleverly accounted for the expected HP DV if you selected a set with Hidden Power, but didn't have it update (properly) if you selected Hidden Power as a move after the fact. Fixed, thanks!

https://replay.pokemonshowdown.com/smogtours-gen8nu-503196

Maybe it's impossible to fix in the calculator then? What I am trying to say is that Silvally forms with the memory equipped are always taking itemless damage as it is impossible to knock them, but the calc defaults to normal, item equipped damage. This replay shows it taking 12%, but this is impossible for item equipped damage and the item cannot be removed from Silvally.

They're both my teams being used, so I know for a fact the 12% damage is only accurate if itemless damage is being done:

252 Atk Mold Breaker Sawk Knock Off (97.5 BP) vs. 0 HP / 0 Def Silvally-Dark: 53-63 (16 - 19%) -- possible 6HKO
252 Atk Mold Breaker Sawk Knock Off vs. 0 HP / 0 Def Silvally-Dark: 36-43 (10.8 - 12.9%) -- possible 8HKO
This was a bug related to the interaction of Mold Breaker and a misunderstanding of how memory items work (ie. theyre dependent on the species, not the ability), thanks!
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
so idk if this got reported yet, but i believe having dynamax set in gen8 randbats, to changing to gen6 randbats, leave the dynamax turned on.

damage is shown as 43.7% which isnt the case as it does 87.4% max (doubled)

after refreshing the page the correct numbers are shown, couple people had the same result as me

edit: quickly checked and this is the same for all gens
fixed
 
Farfetch'd is not in gen 7 nor gen 8 rand calc

ty about showing me how to use the forme selector in a previous comment
 

Austin

Schismatic
is a Programmeris a Forum Moderatoris a Community Contributoris a Battle Simulator Moderator Alumnus
Moderator
Moves are still being boosted by the effects of sun and rain when being used against a pokemon with Utility Umbrella.





This is also working on showdown, here's a replay with the same bulk on koko (To live a specs hydro pump when not in rain)
With Umbrella:
https://replay.pokemonshowdown.com/gen8nationaldex-1139088930

Without Umbrella
https://replay.pokemonshowdown.com/gen8nationaldex-1139089650

While I'm not showing screenshots, this is also not working for sun.
should be fixed thanks for the report!
 

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

Top