1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. If your account is currently registered using an @aol.com, @comcast.net or @verizon.net email address, you should change this to another email address. These providers have been rejecting all emails from @bulbagarden.net email addresses, preventing user registrations, and thread/conversation notifications. If you have been impacted by this issue and are currently having trouble logging into your account, please contact us via the link at the bottom right hand of the forum home, and we'll try to sort things out for you as soon as possible.
  3. Bulbagarden has launched a new public Discord server. Click Here!

The Reffing Calculator

Discussion in 'General' started by Ash K., Oct 8, 2011.

  1. Ash K.

    Ash K. ★The Wrath of Hoenn★

    Blog Posts:
    0
    Joined:
    Apr 17, 2010
    Messages:
    3,993
    Likes Received:
    164
    This is a major issue and it needs to be solved.

    As you know, it is possible for the reffing calc to show HP equal to 1 HP less than the % indicates. Many people have the wrong impression of how this works. Let's take Staraptor's Close Combat on Tyranitar.

    Staraptor using 120 BP Fighting Physical on Tyranitar.

    On URPG Reffing Calculator it shows 0 HP and 0.25%.

    On URPG Reffing Calculator it shows 1 HP and 0.25%.

    Now let's take Excadrill. It is Ground/Steel type and has 424 HP. As you probably know, Steel types are immune to Poison type moves. So if you use a Poison move on it it's health should remain unchanged, right? Put it at 423 HP and have Gengar repeatedly Sludge Bomb it (90 Poison Special). You'll find it takes damage until it reaches 87.5%.

    This is a very important issue that can sometimes change the outcome of a battle.

    I want to hear your thoughts on the matter, and possible solutions.

    And no Mav, this is not the place to just say "I don't care, I'm the ref" as you have several times before.

    @~Near @Alaskapigeon @AmericanTreeFrog @Ataro @august13th @Bumblebee @Buzzer @Captain Dude @ChainReaction01 @derian @DrStubbsberg @Ebail @Eeveedude @Fierce Deity @FlammenWarfare @Fossil Fusion @gmandiddy @husnain @iReign @MaverickKaiser @Monbrey @Mubz @Neonsands @Nitro @Roulette @Scourge of Nemo @SiberianTiger @Synthesis @The Crimson Rose @Team Evolution @TheEvilDookie @The Jr. Trainer @The pokemaster @Toxophilite @Volcanflame @We Taste Pies... @WebMaster @WinterVines @Xali @Zeferin

    I mentioned all the refs I could think of that were active (I'm not sure if there's actually an up to date list of refs anywhere). If you think of someone else please show them this thread somehow.

    Damnit Pidge, why do you have a name that you can't do anything with? :|
     
    Last edited: Oct 8, 2011
  2. The Jr. Trainer

    The Jr. Trainer Stay Classy

    Blog Posts:
    0
    Joined:
    Mar 11, 2010
    Messages:
    986
    Likes Received:
    12
    If you even try to calc damage for a poison move on a steel Pokemon you shouldn't be a ref.

    Other than that, Monbrey has to change the formula on one of them to make them do the same damage amount. And if it is that big of a deal you can take the % left on the Pokemon and multiply it by the max HP of the Pokemon to see how much raw HP it should have left.
     
  3. Team Evolution

    Team Evolution WATER MASTER!

    Blog Posts:
    0
    Joined:
    Apr 6, 2010
    Messages:
    856
    Likes Received:
    3
    Answered.

    In this case 404 x 0.25% = 1.01

    round down = 1hp left = ALIVE

    Edit:

    To give another example.

    An x Pokemon with 384hp (eg Abomasnow) is left to show with 0.25% left. Although two calcs (A and B) show 1hp and 0hp respectively. If you do the calculation 384hp x 0.25% = 0.96. Always round down to the nearest whole number = 0 HP = DEAD

    Edit2:
    I̶ ̶w̶o̶n̶'̶t̶ ̶e̶v̶e̶n̶ ̶a̶d̶d̶r̶e̶s̶s̶ ̶t̶h̶e̶ ̶S̶t̶e̶e̶l̶ ̶v̶ ̶P̶o̶i̶s̶o̶n̶ ̶"̶p̶r̶o̶b̶l̶e̶m̶"̶ ̶.̶_̶.̶

    Edit3:
    @ Steel v Poison. The calc is probably set with Steel being not immune to Poison.
     
    Last edited: Oct 8, 2011
  4. Monbrey

    Monbrey Pyromaniac

    Blog Posts:
    0
    Joined:
    Apr 20, 2010
    Messages:
    6,305
    Likes Received:
    450
    This issue has been brought up before, and no definitive solution was found. I was aware of the issue when I originally rewrote the calc, but found no reason for it to be doing it in the formula. The raw damage and raw HP remaining don't line up, and so the percentage therefore can't match both. Last time this came up Pidge put forward a new formula which meant the percentage did match the HP... but then the damage displayed was wrong instead. Either way, there was a 1 point inconsistency, and it doesn't seem to be in the damage equation, it's elsewhere. I'll look into it when I have the time. For now, Pidge should just make a decision towards what we go by, the HP or the percentage, so all refs can at least be consistent and thus avoid "BUT THE HP/PERCETNAGE ISNT AT 0 YET!" arguments.

    As for the Poison vs Steel thing, although I completely agree that any ref should know better, the calc should know better too. Ground doesn't effect Flying types, and the same should be true here. I'll fix that tomorrow.
     
  5. Turtwig A

    Turtwig A Stumped

    Blog Posts:
    0
    Joined:
    Nov 6, 2010
    Messages:
    2,034
    Likes Received:
    2
    If you don't like the way it is, use the real reffing formula, it's found somewhere in the ref encyclopedia or some other site iirc. It should usually be right.
     
  6. Mubz

    Mubz Unregistered user

    Blog Posts:
    0
    Joined:
    Apr 24, 2010
    Messages:
    2,141
    Likes Received:
    2
    I dont know much about the damage formula n such, but wouldnt the damage be rounded rather than the actual hp left?
     
  7. Siless

    Siless Somewhat Psychic

    Blog Posts:
    0
    Joined:
    Apr 30, 2010
    Messages:
    1,287
    Likes Received:
    12
    The formula itself was removed from the 'pedia for some reason, and everywhere else that documents it has the random number variable that the games use that we don't. Last I checked (though I could've gotten it wrong), the input for the random variable we use here isn't any of the extremes, and I'm not trying to find what it is anymore, so until someone finds out/reveals it, we can't exactly use it.
     
  8. Ash K.

    Ash K. ★The Wrath of Hoenn★

    Blog Posts:
    0
    Joined:
    Apr 17, 2010
    Messages:
    3,993
    Likes Received:
    164
    The calculator doesn't have a minimum damage iirc, if you put in Charmander Att-6 using Scratch on Aggron Def+6 Ref @ Chilan Berry it does 0 damage, both according to HP and %. At least, if Aggron starts from full health. If Aggron starts injured by 1 the HP goes down by 1 and the % remains unchanged. The same is true for the Excadrill example. As far as I can tell, the % seems correct but the HP is wrong. Because the calculator deals damage in terms of HP, after the first attack it uses the incorrect HP and deals 1 extra damage according to % and 2 according to HP, and so on. For some reason there are some HP amounts that stop this glitch, at least when doing 0%/1HP. There was a post on this a while ago, the link to which is in my sig.
     
  9. WinterVines

    WinterVines Virbank Gym Leader

    Blog Posts:
    0
    Joined:
    Sep 21, 2010
    Messages:
    6,198
    Likes Received:
    279
    Like Si said, the damage formula doesn't work for what we use because of the random number generated. When you take both minimum and maximum damage from the formula and take the average of both values, it isn't even the damage that we get with ours, being off by a few HP. I used the Weavile Vs. Tyranitar with Low Kick calc, getting 403 damage with our calculator but only getting 402 with the formula version.

    Also, when looking at the damage formula, it says on the info page that rounding is necessary to do at every stage in order for it to work correctly (rounding off to the closest non-decimal number at each stage, iirc). It's unfortunate that we can't even use the formula to work around this issue. I do like Jr and Keta's fixing response, if you didn't want to just check the HP value from the damage box and subtract that instead of just using the percents.
     
  10. Pidge

    Pidge a

    Blog Posts:
    0
    Joined:
    Mar 24, 2010
    Messages:
    3,932
    Likes Received:
    3
    There's actually two problems about the reffing calc. The damage in the test calc and the full-featured calc are BOTH off. The other problem is that in the full featured calc, the result damage box and the box displaying the Pokemon's remaining HP don't add up (literally). Let's take a look at the damage formula, as according to Smogon:

    The Complete Damage Formula for Diamond & Pearl (D/P) - Smogon University

    "Damage Formula = (((((((Level × 2 ÷ 5) + 2) × BasePower × [Sp]Atk ÷ 50) ÷ [Sp]Def) × Mod1) + 2) × CH × Mod2 × R ÷ 100) × STAB × Type1 × Type2 × Mod3)"

    "It should be immediately mentioned that after successfully performing an operator (an operator being +, -, × or ÷), you need to "round down" the number to the nearest whole number before performing the next one. In simple terms, this means to remove all the numbers to the right of the decimal point every time the answer is a decimal before proceeding with the next arithmetic operation."

    So basically you round down to the nearest whole number after each operation.

    The URPG follows that formula to the dot, except one part, which is the R value. This is the random number that can give you varying damage in Pokemon. In URPG, we use the value 92.5 for R, since it is the median of the numbers R can be, 85-100. R only being 85-100 is a relatively new discovery: Smogon Community, but I don't think it really accounts for the errors we see, although the new calc I'll post later does use this new information. Let's manually calculate the damage Staraptor does to Tyranitar with Close Combat, and no other modifiers.

    (((((((100 × 2 ÷ 5) + 2) × 120 × 339 ÷ 50) ÷ 319) × 1) + 2) × 1 × 1 × 92.5 ÷ 100) × 1 × 2 × 2 × 1) = 400

    REMEMBER TO REMOVE ANY DECIMALS (ROUND DOWN TO NEAREST WHOLE NUMBER) AFTER YOU CALCULATE EACH OPERATOR.

    Tyranitar starts with 404 HP.
    On URPG Reffing Calculator the damage is -403 and leaves Tyranitar with 0 HP.
    On URPG Reffing Calculator the damage is -403 and leaves Tyranitar with 1 HP.

    We can try another example. Let's do Togekiss using Flamethrower on Metagross.

    (((((((100 × 2 ÷ 5) + 2) × 95 × 339 ÷ 50) ÷ 279) × 1) + 2) × 1 × 1 × 92.5 ÷ 100) × 1 × 2 × 1 × 1) = 180

    Metagross starts with 364 HP.
    On URPG Reffing Calculator the damage is -181 and leaves Tyranitar with 182 HP.
    On URPG Reffing Calculator the damage is -181 and leaves Metagross with 183.

    If you are following closely, you notice that the damage the calc finds is not equal to the damage we get manually using the formula. Furthermore, on the new calculator, the damage that a Pokemon is left with does not match the damage that it says its done. These are the two problems I mentioned at the begining of this post, I'm just proving it to you now.

    So how do we fix it? Well Espeon (you probably don't know him) and I looked at the source code of the the 99k calc and found the part with the damage formula. There was probably some rounding errors due to slightly incorrectly written code, and the slight change with the new R value may have affected it, I really didn't want to go through the math to find out. Instead of finding what was wrong with it exactly, I just replaced the whole formula, making sure it was written exactly like the one I just showed. I tried it out, and the result damage was correct! However, the second problem, about the result damage not matching with the Pokemon's remaining HP still remained. After Espeon looked at the code for a while, he got it! and explained:

    [​IMG]
    You're movin' with your auntie and uncle in Bel-Air.


    [16:44:16] EspeonofPE2k: okay so
    [16:44:22] EspeonofPE2k: at the end of making the % and the tenths
    [16:44:35] EspeonofPE2k: well
    [16:44:42] EspeonofPE2k: first it takes the total HP left and subtracts the damage
    [16:44:46] EspeonofPE2k: so like 354-180
    [16:44:50] EspeonofPE2k: 364
    [16:44:55] EspeonofPE2k: returns 184
    [16:45:05] EspeonofPE2k: so it takes the percent which is like 50.blahblah
    [16:45:14] EspeonofPE2k: but at the very end, it does something unnecesssary
    [16:45:38] EspeonofPE2k: it remodifies the current HP again by taking the percent and multiplying it by HP
    [16:45:40] EspeonofPE2k: in theory, should work
    [16:45:59] EspeonofPE2k: but here's the error
    [16:46:20] EspeonofPE2k: it takes the % and cuts off all decimals except for the first 2
    [16:46:23] EspeonofPE2k: so 5.2323q345234524352
    [16:46:25] EspeonofPE2k: becomes 5.23
    [16:46:31] EspeonofPE2k: and all those numbers behind it are important
    [16:46:44] EspeonofPE2k: so you end up with a lower value than what it actually is
    [16:47:07] Zoa: ah ok
    [16:47:12] EspeonofPE2k: go down to the Roll_dice function
    [16:47:20] EspeonofPE2k: and then look at the else block right above it
    [16:47:31] EspeonofPE2k: and delete the line that says
    [16:47:32] EspeonofPE2k: document.reffing.DP.value = Math.floor(parseFloat(document.reffing.percent.value) * .01 * parseInt(document.reffing.HP.value));

    So here is the modified version of the calc, don't worry about the buttons. When Monbrey hosts this version, he can fix the button images.

    fixcalc - URPG Stuff

    Please test it out to make sure everything works correctly.

    Oh yeah, and if a Pokemon has 0 HP in the HP remaining box, it's KOd, even if the % says something like 0.24%. This has what it has been like for a while.
     
    Last edited: Oct 8, 2011
  11. Team Evolution

    Team Evolution WATER MASTER!

    Blog Posts:
    0
    Joined:
    Apr 6, 2010
    Messages:
    856
    Likes Received:
    3