1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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 drop bear

    Joined:
    Sep 23, 2013
    Messages:
    377
    Likes Received:
    676
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    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:
    950
    Likes Received:
    625
    @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:
    182
    Likes Received:
    65
    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:
    950
    Likes Received:
    625
    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:
    182
    Likes Received:
    65
    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:
    950
    Likes Received:
    625
    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:
    182
    Likes Received:
    65
  28. Joyverse

    Joyverse Road Roller time!

    Joined:
    Aug 23, 2014
    Messages:
    1,461
    Likes Received:
    788
    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:
    950
    Likes Received:
    625
    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 Road Roller time!

    Joined:
    Aug 23, 2014
    Messages:
    1,461
    Likes Received:
    788
    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:
    950
    Likes Received:
    625
    ???
    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 Road Roller time!

    Joined:
    Aug 23, 2014
    Messages:
    1,461
    Likes Received:
    788
    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
  33. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    950
    Likes Received:
    625
    i changed literally everything. this is a good way to use git
    https://sulcata.github.io/sulcalc/

    gen 7 support is probably pretty poor right now. I'll add things as I read up on them and as people tell me shit.

    if anyone is interested in adding translations, i've copied over most of the things i need from PO, but there are still calc specific things that could be translated. PM me and I can walk you through it.
     
    Zoroark and Joyverse like this.
  34. Zoroark

    Zoroark Awoo Forum Moderator Server Moderator Forum Moderator Server Moderator

    Joined:
    Jan 29, 2013
    Messages:
    850
    Likes Received:
    1,131
    PO Trainer Name:
    SkyPhoenix / Zoroark
    The changes doesn't seem to apply when I switch to, for example Spanish.

    It also seems to be a bit unresponsive when I try to pick a Pokémon that apparently has no predetermined set,for example I tried putting Zorua on the Pokemon search bar, didn't work, I just typed the name, clicked on any blank space and the Pokémon name is gone, I only had the option on clicking a predetermined Pokémon set.

    "More Options" is blank, although I suppose this is part of the stuff that you mentioned is still yet to be added so I won't mind that much. Also I find it funny how in the EVs and Level boxes you can add 0's infinitely, although it ends up correcting itself after you click out of the box so that doesn't matter much.
     
  35. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    950
    Likes Received:
    625
    Pokemon don't have any translations for Spanish from what I could find in PO's translation files, just moves and abilities iirc. I haven't actually translated anything, those are just placeholders for if anyone decides they want to finish the translation files.

    You have to actually click on a set. If you don't want a premade set then click "Blank Set".

    Yes.

    edit: btw you can find the probability for multihit moves like bullet seed without assuming that it'll be exactly n-hits. I also implemented like none of gen 7, forgot to actually finish z-moves before i uploaded lol.
     
    Last edited: Apr 5, 2017
  36. Zoroark

    Zoroark Awoo Forum Moderator Server Moderator Forum Moderator Server Moderator

    Joined:
    Jan 29, 2013
    Messages:
    850
    Likes Received:
    1,131
    PO Trainer Name:
    SkyPhoenix / Zoroark
    Concerning names there's nothing to translate barring type:null's name which is actually there. So I guess it's all about installing-adding the translations that are in the files and that's pretty much it. Moves, abilities, berries and other items are fully translated. I guess the only thing that requires translation are phrases like "guaranteed" or "after spikes/stealth rock damage" and things like that. I can work on that if you wish.

    Also the search bar should be displaying results for every Pokémon that could use a blank set, cause for example: While typing "houndo.." the bar instantly shows me houndoom, that's about right. But when I do stuff like "Alaka..." or "Aboma..." it simply tells me to change the search query.
     
    sulcata likes this.
  37. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    950
    Likes Received:
    625
    Translating the actual damage report might be slightly complicated across languages since grammatical structures can vary greatly. It's also sort of integrally located in an API that I've excluded from the user interface, so I'll need to either look into extracting it or into creating some sort of translation injection. Could be something interesting for me to figure out.

    Working on those would be great. I've added a section in the OP on how to translate these things.
    https://github.com/sulcata/sulcalc/blob/master/app/translations/es.js
    https://github.com/sulcata/sulcalc/blob/master/app/translations/languages.js
    These would be the two files you'd need to edit. In the first file you'd need to edit everything in quotes (after the import section). In the second file just replace your language with the translated version.

    --- Post updated ---
    Also I think I've found the issue with searching Pokemon. Pretty sure it has something to do with casing. I'll look into it after dinner.

    --- Post updated ---
    Actually I think the issue is with the select component I'm using. It'll hopefully get fixed relatively soon. If not I'll start looking into alternatives (I kind of like how this select component works though :( )

    edit: added gravity and thousand waves
     
    Last edited: Apr 6, 2017
  38. Zoroark

    Zoroark Awoo Forum Moderator Server Moderator Forum Moderator Server Moderator

    Joined:
    Jan 29, 2013
    Messages:
    850
    Likes Received:
    1,131
    PO Trainer Name:
    SkyPhoenix / Zoroark
    Excuse the terrible delay, I suffered from massive procrastination. I have submitted the Pull Requests for the translations (note the comment I left on the first PR) hopefully everything went out fine, let me know if it any error showed up.
     
    sulcata likes this.
  39. magic9mushroom

    magic9mushroom Active Member

    Joined:
    Dec 22, 2012
    Messages:
    182
    Likes Received:
    65
    Seems to have disappeared in the new version. :(
     
    sulcata likes this.
  40. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    950
    Likes Received:
    625
    Those could get a bit long and ugly. They're still calculated, but idk where to put them. Any ideas?
     
  41. sulcata

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

    Joined:
    Jun 13, 2012
    Messages:
    950
    Likes Received:
    625
    well, I added the option all by its lonely self in the "More Options" tab.

    Apparently I fucked around with gsc crit mechanics and broke them. Should be fixed now, and shouldn't happen again since I added in regression tests for that.