1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Cloudflare Security Issue - Change Your Passwords!

    Hello there, Guest!

    Cloudflare, the internet proxy we use to protect ourselves against DDoS and other malicious attacks, reported on 23rd February 2017 that they had patched a bug reported by Google's Project Zero that was exposing sensitive information in random requests, approximately 0.00003% of all requests, since September 2016.

    Whilst it is unlikely that any information has been leaked from this website, we recommend that all users change their passwords here on the Pokémon Online forums, as a precaution. Remember to use a unique and secure password for every site that requires one.

    We apologise for any inconvenience caused.

    Dismiss Notice

It's a Damage Calculator!

Discussion in 'Technical Projects' started by sulcata, Jun 10, 2014.

  1. DSM01

    DSM01 Jammin' out

    Joined:
    Aug 7, 2011
    Messages:
    705
    Likes Received:
    59
    Desolate Land (harsh sun) is halving Fire type moves instead of giving them a 50% boost.
     
  2. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    Fixed Desolate Land.
    silly typo, I had 0x800 instead of 0x1800

    You caught that at a good point as I have made my calculator stop using recursion to calculate probability, which makes it a lot faster and "more accurate" (I'll probably need to make a BigInt class just for this).
    oddly enough honko and myself came up with just about identical formulas for recursively calculating probability aside from his "squashing" of multihit damage ranges
     
  3. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    Okay, I implemented really really fat integers so probability calculation is "perfect" and fast.
    Let me know if I broke something along the way.

    I'll probably revamp the GUI or something next.
     
  4. Dr. Doom

    Dr. Doom Long time hater of stall

    Joined:
    Jan 1, 2012
    Messages:
    2,123
    Likes Received:
    109
    Some weird glitch happened today where only one side of the calculator was showing. I tried closing down and opening it up again, but that didn't work.

    Screen Shot 2014-12-26 at 21.31.20.png
     
  5. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    I'm planning an overhaul of the gui anyway but...
    I think it was because I minified the HTML source that this happened. No idea why it happened for Safari only though. Thanks @Duster for checking if it was fixed.
     
    Last edited: Jan 11, 2015
  6. froggy25

    froggy25 Member

    Joined:
    Jun 7, 2013
    Messages:
    32
    Likes Received:
    20
    Last edited: Jan 28, 2015
  7. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    Oh I tried to simplify some of my code and forgot to account for hidden power, so it's calculating it as physical it seems lol. I'll fix it in a bit (and edit post when fixed etc. etc.)

    edit: ok pretty sure i fixed it Misdreavus Hidden Power [Fire 70] vs. Leftovers Steelix: 120 - 142 (34 - 40.2%) -- guaranteed 3HKO after Leftovers

    there were also a few micro-optimizations i made that actually made a slightly notable difference (not constantly asking for the length of a node collection). I also noticed an issue with probability calculation. I don't think it actually produced incorrect results which was the funny part. It just took up a little extra memory.
     
    Last edited: Jan 28, 2015
  8. froggy25

    froggy25 Member

    Joined:
    Jun 7, 2013
    Messages:
    32
    Likes Received:
    20
  9. Dr. Doom

    Dr. Doom Long time hater of stall

    Joined:
    Jan 1, 2012
    Messages:
    2,123
    Likes Received:
    109
    Acrobatics doesn't work:

    Screen Shot 2015-01-29 at 16.22.04.png
    Screen Shot 2015-01-29 at 16.22.13.png
    It did the exact same damage even with no item.
     
  10. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    It is fixed, I just forgot to update the gh-pages branch.
    also fixed doom's thing.
     
    Last edited: Jan 30, 2015
    froggy25 likes this.
  11. Dr. Doom

    Dr. Doom Long time hater of stall

    Joined:
    Jan 1, 2012
    Messages:
    2,123
    Likes Received:
    109
    Just a suggestion, I think you should reconfigure the attacking Pokémon section to this:

    No Set
    Fast Physical Attacker
    Fast Special Attacker
    Bulky Physical Attacker
    Bulky Special Attacker
    Mixed Attacker

    I think the physical and special Life Orb sets and Choice sets are fairly redundant, as it's a matter of moments to change the item.
     
    sulcata likes this.
  12. Disaster Area

    Disaster Area Badged Deucer

    Joined:
    May 10, 2013
    Messages:
    605
    Likes Received:
    183
    PO Trainer Name:
    Disaster Area
    :o since we can play inverted in other gens can you add past gens support for it?

    Also the ability to calc with custom moves would be great (think from anything like CAP, there's a lot of projects like this around) [i.e. have the option custom and be able to edit type, power, and anything that's in the mechanics of another move [e.g. knock off's power adjustment, presence of 2ndary effects+sheer force] altho some might be unnessecary/overcomplex enough to leave alone]
     
    Last edited: Feb 16, 2015
  13. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    No, you can just change the types if you want to control that. I originally intended them to be an easy solution to things like Conversion, Soak, and Protean, but I guess they can be used for that too.

    Already said no to CAP; it's not popular enough to justify more code bloat. I might add a (Custom Move) option to the list, but I worry that people will start calculating base power on their own, which they do improperly 99% of the time basing it on STAB and type effectiveness.
     
  14. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    Double post wheee

    I added support for Sitrus Berry, Oran Berry, Figy Berry, Wiki Berry, Mago Berry, Aguav Berry, Iapapa Berry, Berry (gsc), and Gold Berry (gsc). So now it takes into account that certain damages will trigger berry healing, while others will not.

    Also apparently I broke the link to calculation thing when I tried to make it faster. So I "fixed" it by basically commenting stuff out. I'll be working on a proper fix in the meanwhile, but at least the links work again. I know what broke it and it's awkward to say the least.
     
    Disaster Area likes this.
  15. Duster

    Duster hippies suck Forum Moderator Developer Forum Moderator Developer

    Joined:
    Sep 23, 2013
    Messages:
    375
    Likes Received:
    664
    u should add hackmons sets!!!!
     
    sulcata likes this.
  16. Dr. Doom

    Dr. Doom Long time hater of stall

    Joined:
    Jan 1, 2012
    Messages:
    2,123
    Likes Received:
    109
    What would be the point? Just change the original Pokémon's ability. And you can already give them 252 EVs in everything:
    Screen Shot 2015-05-23 at 20.38.46.png
     
    Last edited: May 23, 2015
  17. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    he was uh, trolling maybe a little

    I added in a "set hp" button, so you can now set the opposing pokemon's HP based on the range of damage dealt by the last attack used. It's right next to the individual expected damage values. This feature does include Leftovers, Sandstorm, and all the other residual effects built in to the calculator.

    [​IMG]

    i.e. click calculate on body slam, click set hp, click hyper beam to find the chance of Body Slam + Hyper Beam KOing chansey.

    This has the added effect of allowing you to change stat boosts/drops after setting the HP, meaning that you can find out just how likely say, 2 Latios Draco Meteors are to KO an opponent, or how likely you are to KO after getting your Choice item knocked off, etc.

    Note that I'm still planning to code the 100% stat changes at some point in the future.

    You can manually input the range of HP for the defender only in the following ways:
    • A comma separated list, i.e. 1, 2, 3, 3, 3, 4, 4, 5
    • A weighted comma separated list, i.e. 1:1, 2:1, 3:3, 4:2, 5:1 is the same as 1, 2, 3, 3, 3, 4, 4, 5
    • A min-max inclusive range, i.e. 1-5 is the same as 1, 2, 3, 4, 5 (cannot combine with other methods)
    • A simple number.

    edit: do note that all HP ranges will not be saved in calculation links. Saving that much info into a url would make it massively blow up in size. Instead, the defender's HP is stored as an average of all the values. Similarly, moves with base power depending on HP like Wring Out and Crush Grip will also utilize the average HP. Healing berries will activate based on the variable HP amount from a turn to turn basis and produce accurate probabilities to KO.
     
    Last edited: May 23, 2015
    Dr. Doom, Duster and Disaster Area like this.
  18. Dr. Doom

    Dr. Doom Long time hater of stall

    Joined:
    Jan 1, 2012
    Messages:
    2,123
    Likes Received:
    109
    Just an idea - maybe you could list the Pokémon's base stats as well?
     
  19. SongSing

    SongSing KILLL

    Joined:
    Jan 2, 2013
    Messages:
    641
    Likes Received:
    190
    PO Trainer Name:
    SongSing
    potentially customizable base stats would be good probably in case some cap players want to use it
     
  20. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    Not really enough room at the moment. I'll consider it if I ever get around to overhauling the GUI (likely not happening).

    If I add it in, then it'll be under "more options" or whatever I called it (the button near gen selection), as I don't want people to start doing silly things like doubling base stats instead of just using Huge Power and then complaining about inconsistencies. Pretty much the same case for custom moves, although I don't necessarily need to do it during the rehashing of the GUI.
     
  21. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    @magic9mushroom, I made it display the exact fraction(s) for the likelihood to KO. It'll display underneath the damage roll. If there's more than one chance to KO then it'll list all the fractions in order. The HP clearing should be fixed.

    If by "transparency" you meant that the source code was obfuscated, you can see the whole body of code here: https://github.com/Sulcata/Sulcata-Damage-Calculator
    It shouldn't be too bad to follow along if you're fluent in Javascript.
    I just run it through the Google Closure minfier/compiler with default settings for the gh-pages branch. If you run it through yourself you'd get the exact same code.

    If you're referring to the chance to KO, it's just calculated with arrays of values with attached weights. The weights can get kinda big when you start getting into 7HKOs, so I implemented some arbitrary precision arithmetic; although it only handles non-negative numbers since that's all I need for probability.

    From your previous response I'd guess you have thoughts on the four color map theory? :p
     
    Disaster Area likes this.
  22. magic9mushroom

    magic9mushroom Active Member

    Joined:
    Dec 22, 2012
    Messages:
    180
    Likes Received:
    64
    Well, my problem is more with "I don't trust a result without seeing the working" than with "non-constructive proofs are terrible". Although non-constructive proofs are terrible.

    Unless I'm misunderstanding what you're saying?
     
  23. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    no, that's about right. Not trusting a result in which you don't see every piece fitting together, which I don't completely disagree with. Well, I suppose I haven't learned enough proof based mathematics to really comment.

    idk if you're able to read my code or not; I try to format well and comment, although my own code ends up looking cryptic to me at times. I could step through the probability code after calculations if you'd like. Everything calculation and probability related is located under "calculator.js", "ui.js" only plugs the remaining HP back in.

    The functions you'd be concerned with would be located around "function WeightedArray". The non-negative integer arithmetic (i add strings!!!) should be right above as well. The "this.chanceToKO" function is exactly what it sounds like, as is "this.rby_calculate". Ctrl+F should work pretty handily if you search the phrases I quoted. Well, that's if you're interested.
     
  24. Disaster Area

    Disaster Area Badged Deucer

    Joined:
    May 10, 2013
    Messages:
    605
    Likes Received:
    183
    PO Trainer Name:
    Disaster Area
    rip my previous posts :( anyways..

    Just used the calc for the first time that I'ver needed it instead of smogon,s to calculate Moltres vs Staryu Fire Blast+Hyper Beam. Its functionality is very nice, thank you ^.^ When i need to do more calcs of that sort in the future, I shall. :)
     
  25. magic9mushroom

    magic9mushroom Active Member

    Joined:
    Dec 22, 2012
    Messages:
    180
    Likes Received:
    64
    You can't select any status besides Badly Poisoned on a defending Pokemon. It just reverts to Healthy. You can work around it with Swap Pokemon, but it's clearly not working the way it should be (Burned and Poisoned are obviously pertinent on a defender, and Paralysed can be in the case of something like Gyro Ball). They're simulated properly when you use the workaround, you just can't access them normally.


    Badly Poisoned in RBY doesn't seem to be working properly.

    (the following is using the above workaround)
    Burn in RBY seems to be running at 1/8 like later gens, rather than 1/16. Poison appears to be correctly running at 1/16, though.



    EDIT: Also, the description when chances of an NHKO are very low seems to be bugged.

    They should be "possible 3HKO" and "possible 8HKO", or "guaranteed 4HKO" and "99.1% chance to 9HKO".
     
    Last edited: Oct 24, 2015
    Disaster Area likes this.
  26. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    The issue with status selection is fixed. I meant to reset the Toxic counter value to 0 on selecting a new status, but for some reason I reset the status value 0, which is (No Status).

    I was not aware that burn was also 1/16th. I've fixed that too. Do note that while Burn has been fixed, calculations like:
    will not work for now due to the calculator lagging out in very specific scenarios such as GSC multihit moves and Psywave, forcing me to limit NHKO to 9 maximum.
    Toxic should also be working in terms of calculations.

    Fixed the NHKO issues. It was due to a small problem I created when refactoring that code. A string is definitely not less than a number, bar type coercion.


    Sorry this took a while, I was closing up some issues with Battle Factory.
     
    Disaster Area likes this.
  27. magic9mushroom

    magic9mushroom Active Member

    Joined:
    Dec 22, 2012
    Messages:
    180
    Likes Received:
    64
  28. Joyverse

    Joyverse Till the very end! Forum Moderator Articles Leader Forum Moderator Articles Leader

    Joined:
    Aug 23, 2014
    Messages:
    1,362
    Likes Received:
    687
    PO Trainer Name:
    Joyverse
    So I tried to calc Bish vs. Mega Medicham. and I got
    252+ Atk Life Orb Bisharp Knock Off vs. 0 HP/4 Def Mega Medicham: 1 - 1 (0.4 - 0.4%) -- this might take a while...


    upload_2015-12-24_16-30-19.png

    WELP!

     
    sulcata likes this.
  29. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    seems like a good damage roll to me

    edit: I can't reproduce that in the online version or my own local copy.
     
    Disaster Area likes this.
  30. Joyverse

    Joyverse Till the very end! Forum Moderator Articles Leader Forum Moderator Articles Leader

    Joined:
    Aug 23, 2014
    Messages:
    1,362
    Likes Received:
    687
    PO Trainer Name:
    Joyverse
    ._.) Huh?
     
  31. sulcata

    sulcata cory is #1 bae Tiering Administrator Server Administrator Tiering Administrator Server Administrator

    Joined:
    Jun 13, 2012
    Messages:
    941
    Likes Received:
    616
    ???
    Are you able to input the same information and get the same error? Because I put in exactly what you had on screen and got the correct damage. If it's still happening then send me a link to it.
     
  32. Joyverse

    Joyverse Till the very end! Forum Moderator Articles Leader Forum Moderator Articles Leader

    Joined:
    Aug 23, 2014
    Messages:
    1,362
    Likes Received:
    687
    PO Trainer Name:
    Joyverse
    Ah alright. Gotcha.

    [​IMG]

    Problem still persisting even am using a different connection plus different PC.
    EDIT: I shud have edited earlier, I get no problems now! :)
     
    Last edited: Jun 19, 2016