1. Welcome to Smogon Forums! Please take a minute to read the rules.

# Probabilities of Hax

Discussion in 'Stark Mountain' started by TAY, Feb 4, 2009.

1. ### TAYYou and I Know

Joined:
Nov 7, 2007
Messages:
1,542
It has happened to everyone - you think you have the game won, but then an Ice Fang freeze or an untimely critical hit snatches the match right out of your hands. And I am sure that most people have heard their opponent blame "hax" for their loss, and then you smugly think "I would have won anyway."

But how much luck really constitutes hax? Being struck with a critical hit near the end of the game can be crucial, but where is the line that sets apart "bad luck" from "probability"? The purpose of this post is to start a discussion regarding the extent to which we accept the luck factor of the game. When you attack an opponent's pokemon 16 times in a row, do you expect to get a critical hit? Would you consider it hax when you do?

When Focus Blast misses, is that considered hax? What about if it hits three times in a row? The probabilities are similar - 30% vs 34.3% - but we intuitively assume that hax only occurs with the most obvious lower probability.

In this thread I will be providing statistics on the chance for a "hax" event to occur with a certain number of attacks. A lot of the chances involved are surprisingly low or high, and it will make you see how incredibly difficult it is to have a hax-free game.

Case 1: Chance of a Critical Hit with N attacks
This case involves moves like Return, which have no extra effects. It is the most basic, and the way to calculate it is fairly intuitive. In brief, you take the chance of the event not happening, bring it to the Nth power, and subtract that number from 1. That is the probability of an event occurring at least once given N iterations. So the chance to critical hit with a single attack is 1 - .9375 ^ 1 (remember, .9375 = 15/16); with two 1 - .9375 ^ 2, and so on.
Code:
```Chance of a critical hit occurring with N attacks
1 attack(s)............0.0625
2 attack(s)............0.12109375
3 attack(s)............0.176025390625
4 attack(s)............0.2275238037109375
5 attack(s)............0.2758035659790039
6 attack(s)............0.32106584310531616
7 attack(s)............0.3634992279112339
8 attack(s)............0.4032805261667818
9 attack(s)............0.4405754932813579
10 attack(s)...........0.47553952495127305
11 attack(s)...........0.5083183046418185
12 attack(s)...........0.5390484106017048
13 attack(s)...........0.5678578849390983
14 attack(s)...........0.5948667671304047
15 attack(s)...........0.6201875941847543
16 attack(s)...........0.6439258695482072
```
This is not particularly impressive; however, the chance to score a critical hit is fairly low. But what happens when we throw additional effects into the mix?

Case 2: Chance of a Critical Hit OR 10% Effect with N attacks
This case involves moves like Flamethrower, which has both a 1/16 chance to score a critical hit and a 1/10 chance to Burn. Since the two effects are not mutually exclusive (that is, they occur independently of one another), the chance for one of the events to occur is: (Chance of Crit) + (Chance of Burn) - (Chance of Crit AND Burn) = .15625, which is roughly 15.5%. Now let's pan this out over several attacks, using the same technique as in Case 1:
Code:
```Chance of a critical hit OR a 10% effect occurring with N attacks
1 attack(s)............0.15625
2 attack(s)............0.2880859375
3 attack(s)............0.399322509765625
4 attack(s)............0.4931783676147461
5 attack(s)............0.572369247674942
6 attack(s)............0.6391865527257323
7 attack(s)............0.6955636538623367
8 attack(s)............0.7431318329463465
9 attack(s)............0.7832674840484799
10 attack(s)...........0.8171319396659049
11 attack(s)...........0.8457050740931072
12 attack(s)...........0.8698136562660592
13 attack(s)...........0.8901552724744874
14 attack(s)...........0.9073185111503488
15 attack(s)...........0.9217999937831068
16 attack(s)...........0.9340187447544964
```
Here you can see that the probability of a "hax" event occurring when using this type of attack increases very quickly! In fact, by the time the fourth attack is used, the chance of a player getting haxed is very nearly 50%. This means that if each player uses Flamethrower twice in a row, there is about a coin flip's chance that at least one player will be hit with either a Burn or a Critical hit. This same formula can be used to calculate the chance of a hax with a 20% effect rate (such as Waterfall or Crunch) or a 30% effect rate (Such as Iron Head or Lava Plume).
Code:
```Chance of a critical hit OR a 20% effect with N attacks
1 attack(s)............0.25
2 attack(s)............0.4375
3 attack(s)............0.578125
4 attack(s)............0.68359375
5 attack(s)............0.7626953125
6 attack(s)............0.822021484375
7 attack(s)............0.86651611328125
8 attack(s)............0.8998870849609375
9 attack(s)............0.9249153137207031
10 attack(s)...........0.9436864852905273
11 attack(s)...........0.9577648639678955
12 attack(s)...........0.9683236479759216
```
Perhaps this is what makes Gyarados so popular? With just two attacks, the chance to score a flinch or crit is greater than the chance of hypnosis missing; with 3, the chance is almost that of hypnosis hitting, and with four the chance to achieve a hax event is almost 70%.

Code:
```Chance of a critical hit OR a 30% effect with N attacks
1 attack(s)............0.34375
2 attack(s)............0.5693359375
3 attack(s)............0.717376708984375
4 attack(s)............0.8145284652709961
5 attack(s)............0.8782843053340912
6 attack(s)............0.9201240753754973
7 attack(s)............0.9475814244651701
8 attack(s)............0.9656003098052679
9 attack(s)............0.9774252033097071
...
```
and just for kicks...
Code:
```Chance of Serene Grace Air Slash flinching N times consecutively
1 attack(s)............0.57
2 attack(s)............0.32489999999999997
3 attack(s)............0.18519299999999994
4 attack(s)............0.10556000999999997
5 attack(s)............0.06016920569999997
6 attack(s)............0.03429644724899998
7 attack(s)............0.019548974931929988
8 attack(s)............0.011142915711200092
...
```
So now you can justify your whining when you get flinched four times in a row by togekiss; the chance is the same as scoring a burn with Flamethrower!

Case 3: Chance of a Critical Hit OR Multiple Effects with N attacks
This case really only applies to the "fang" attacks, which have a 10% chance to either Flinch or Freeze. What complicates this even more is the fact that a frozen foe has a chance to thaw on the first turn (I am using 60 / 256, roughly 23.4%). So let's find the chance to score a flinch OR freeze OR crit, AND NOT have the foe thaw the turn they are frozen, AND have the attack hit:
• First we will find the chance to freeze OR flinch: .1 + .1 - (.1 * .1) = .19
• Next, we will find the chance of this OR a critical hit occurring: .19 + .0625 - (.19 * .0625) = .240625
• Then muliply this chance by the probability of NOT thawing and the probability of the attack hitting: .240625 * (1 - .234375) * .95 = .175017 or about 17.5%.
Of course, the chance for fire fang and thunder fang is slightly higher, since their statuses never "go away". However Ice Fang is probably used much more than both of those combined, so I felt it made more sense to show the calculations for that one.
Code:
```Chance of Ice Fance achieving either a critical hit, flinch, or a freeze, and the foe NOT defrosting the first turn, and the attack hitting
1 attack(s)............0.17501708979999997
2 attack(s)............0.3194031978779387
3 attack(s)............0.4385192695125283
4 attack(s)............0.5367879929412237
5 attack(s)............0.6178580103770678
6 attack(s)............0.6847393892912552
7 attack(s)............0.7399153839060704
8 attack(s)............0.7854346365165802
9 attack(s)............0.8229872420053275
10 attack(s)...........0.8539674997670268
11 attack(s)...........0.8795256829740196
12 attack(s)...........0.9006107473355492
13 attack(s)...........0.9180055650942783
14 attack(s)...........0.9323559924712732
15 attack(s)...........0.9441948498113603
16 attack(s)...........0.953961704793228
```
So if you need a hax event with Gyarados, Waterfall is the way to go (even though it may not seem like it at first).

Here are a few more I found interesting:
Code:
```Chance of a Hax event with N attacks of Thunder
1 attack(s)............0.24062499999999998
2 attack(s)............0.423349609375
3 attack(s)............0.5621061096191406
4 attack(s)............0.6674743269920349
5 attack(s)............0.7474883170595765
6 attack(s)............0.8082489407671158
7 attack(s)............0.8543890393950286
8 attack(s)............0.8894266767905998
9 attack(s)............0.9160333826878617
10 attack(s)...........0.936237849978595
11 attack(s)...........0.9515806173274955
12 attack(s)...........0.9632315312830669
13 attack(s)...........0.9720789440680789
14 attack(s)...........0.9787974481516974
15 attack(s)...........0.9838993121901952
16 attack(s)...........0.9877735401944295
```
Perhaps Thunder could be more useful on a stall team, which frequently has turns to spare? Of course, you would likely need a reliable way of deal with Gyarados!

Code:
```Chance of Focus Blast hitting N times consecutively.
1 attack(s)............0.7
2 attack(s)............0.49
3 attack(s)............0.343
4 attack(s)............0.2401
5 attack(s)............0.16807
6 attack(s)............0.117649
7 attack(s)............0.0823543
8 attack(s)............0.05764801
```
I hope this helps to redefine your idea of "hax". In a single battle, it only makes sense that several hax events would occur, given the number of attacks in a single battle. In fact, not having any of these events occur could be considered hax, since the chance of that happening is obviously very low.

So the next time you are Calm Minding your Suicune against a Magnezone, do not get upset when you get critted or paralyzed by its fourth Thunderbolt!
2. ### Kristoph

Joined:
Jun 10, 2005
Messages:
1,835
This thread is nice, I can't count all of the complaints I've gotten in these sorts of situations so hopefully a few whiners get a "chance" (mmmm) to read this. And really yeah, none of these calculations are exactly difficult so sometimes it can be useful to just have a calculator sitting next for a little on the fly stuff, it's not going to make-or-break you but you never know.
3. ### MatthewI love weather; Sun for days

Joined:
May 26, 2008
Messages:
4,228
Wow, TAY, this was great. =/ I guess I should stop blaming hax now...

damn.
4. ### Legend of Elune

Joined:
Jan 7, 2009
Messages:
39
My own words exactly. .-.
5. ### animenagai

Joined:
Nov 19, 2007
Messages:
1,217
Personally, I think there's always a difference between overall probability and probability of only one single turn. If say I've been flinched by kiss for 10 turns with air slash and perhaps t-wave, one can justify it as being bad luck. However, does that mean you should expect that not to happen next turn? Well, no because there's still around a 70% of you being either paralysed or flinching.

My point is simply that there is a puzzle we need to solve. How do we choose between the improbabilities of long series of events and the improbabilities of one turn? How many turns do we need to calculate before we switch from one to the other? Before we can answer that question I think all our efforts will be in vain.

edit: I also believe that in such a discussion, we need to involve the relevance of the hax. Say if a non-scarfed, non specs'd heatran crits my vaporeon with fire blast on the first switch, I wouldn't think much of it as I can just wish it off. However, if it was late in the game and the same thing happenned to a salamence on the switch, killing it in the process and ending the game, then suddenly it's hax.

Note that in both situations, the probablilty of the crit happening is the same. How do we weight hax? If I critted a bliss with fire blast and you critted my mence late game, are we even? Needs adressing imo.
6. ### ScofieldOoooooooooooohhhhhhhhhhhh hhhhhhhhhhh, Kate.......

Joined:
Sep 14, 2007
Messages:
1,215
Well, Tay, all I can say is I think you'll do just fine in the engineering: probability and statistics class.
7. ### Stathakis

Joined:
Dec 28, 2007
Messages:
2,361
yea right like im gonna stop bitching when my opponent crits my +6 cursepert, but thats greek stubbronness and of course looking for an excuse to bitch about anything.

good job.
8. ### TheorymonDUDELETT DUDE, DUDELETT DUDE, GNARLY GNARLY GNARLY!

Joined:
Jan 14, 2009
Messages:
2,284
Hopefully this well shut up the whiners. Hax is part of the game.
9. ### Potential

Joined:
Oct 12, 2008
Messages:
116
I like this. I've always been doing this in my head during a battle, to see if it's worth it to do something if the plan is more than 1 turn long. Normally, though, I only go with simple hit-miss calculations. These really put things into perspective!

Using these calculations, people could back up either side of the "hax" argument... Hey, they're statistics, after all!

This is why I love math, though: you can use it to model almost anything.
The only problem, about the same one that X-Act is working on, is that whatever you do has to be pretty much infinitely intricate to perfectly suit real life. Or Pokémon life. Whatever.

I think people tend to look at individual turns, since, as we all know, that one irritating critical finishes your game. They don't take into account the fact that (as stated before) if you're playing a decently long battle (read: more than 5-10 turns (estimate)), it's bound to happen, according to the opening post. However, on the other side of the argument, "Why must it happen on that turn?"
10. ### Relictivity

Joined:
Dec 31, 2008
Messages:
476
About +6 Cursepurt... maybe Nintendo but Crits in there to prevent people from stating up to that level? I don't know, just guessing.
11. ### Kristoph

Joined:
Jun 10, 2005
Messages:
1,835
Honestly it's about time people stopped using that term altogether in my opinion lol

Some of the luck based stuff is pretty useful if you ask me. People ignore team matchups and the like (which can be just as "lucky" as actual luck-based mechanics, depending on your team), where I might be screwed against anyone with Cursepurt or what have you, but overall just play better, earn some free turns and get a "lucky kill" as a result. In a way it really does balance out the game.
12. ### bojanglesIF YOU TRULY BELIEVE,

Joined:
May 23, 2008
Messages:
2,910
Erm, not to be argumentative, but I was under the impression that the chances of a Critical Hit stayed constant at 6.25% regardless of how many hits passed without one. Just like how your chances of running into a shiny are 1 in 8192, but after 8191 battles, you aren't guaranteed a shiny.
13. ### Caelumqibz official stalker

Joined:
Apr 5, 2008
Messages:
1,656
TAY is showing the probability of getting 1 critical hit after n turns, he isn't stating anything about the individual turn in question (which is 6.25%).
14. ### 1059860

Joined:
Jan 20, 2008
Messages:
869
Although moves like Stone Edge, albeit high crit ratio, only has 80% accuracy, so that will be different when it comes to CRIT on top of that being factored in.

15. ### billymills

Joined:
Jul 6, 2008
Messages:
3,583
I assume you're using python for these calculations, just to let you know, you can round when there's 10 consecutive 9s. Python does have rounding errors.

Typically, I don't get mad at a single event unless it's crucial. If you're calm-minding 6 times, expect to get frozen or critted, that's why there's subs, etc. An event like focus blast missing is not hax, neither is it hitting 3 in a row. Hax is when an event similar effects the outcome of the game.
16. ### alive

Joined:
Mar 24, 2008
Messages:
459
never once did i think id be reading a logarithmic function in pokemon.
17. ### SoTI leave and they change my avatar to this?

Joined:
Aug 30, 2007
Messages:
1,497
Well...from my own experience bitching about hax, and bitching about hax when it matters is two differently own things. I mean if they get a crit or something that's unnecessary then sure it sucks but whatever, if they get it and it's like game changing then I don't see why you don't have a "legitimate" reason to get pissed off. Probably just cause I'm the one usually on the recieving end. ;)
18. ### chenman333

Joined:
Aug 26, 2008
Messages:
742
Nice job with the probability aspect of "hax." Some good lessons there if you plan on taking AP Statistics guys :P

But yes, this does show that as the battles go on, you are bound to get a bit lucky, which is why "haxless" matches are so rare. The chance of a crit may only be 6.25%, but since you attack so often (offensive teams especially), after even just 10-12 turns, the odds of someone getting a critical hit is almost 1/2. This is why a move like Ice Beam is great to spam against stat uppers (like CMer) since even after just four attacks, the odds are very much in your favor that you are about to screw them over with a freeze or a crit that bypasses those boosts.

^^^^ As for getting hax at crucial moments, yes it sucks, but hax is independant. It's not as if Shoddy recognizes you are about to win and decides to hax you. But you definitely do have the rights to bitch about it, because if it was that gamebreaking, everyone will know who really should have won that.
19. ### memorexia

Joined:
Aug 13, 2007
Messages:
51
You've got to add Parafusion :P
20. ### chenman333

Joined:
Aug 26, 2008
Messages:
742
Never mind this, parafusion is multipicative.
21. ### billymills

Joined:
Jul 6, 2008
Messages:
3,583
you could say that, but you'd be wrong
parafusion depends on what you are expecting (37.5 chance to attack, 62.5 chance to fail)

Chance to fail n times:
1. .625
2. .390625
3. .244140625
4. .152587890625

Chance to succeed n times:
1. .375
2. .140625
3. .053734375
4. .019775290625

Etc. not counting the fact that confusion usually doesn't last 4 turns, and the possibility of confusion disappearing.
22. ### chenman333

Joined:
Aug 26, 2008
Messages:
742
^^^ Eh? 37.5% chance to attack? According to Bulbapedia, it should be 25%, because paralysis is 1/4 of the time and confusion is 1/2 of the time.

And I forgot Confusion lasts only four turns.

But anyway, I calculated my numbers like TAY's as in, the odds of hitting on the 3rd shot (granted you missed the last two times). Like that. You calculated the odds of failing x times in a row, or hitting x times a row. We're both right in what we are calculating (our raw numbers are different though).
23. ### billymills

Joined:
Jul 6, 2008
Messages:
3,583
Odds of hitting after n attempts would be as follows:

1. .375
2. .609375
3. .755859375
4. .847412109375
5. .904632568359375

or 1 minus the number 1 got in my first set.
24. ### Relictivity

Joined:
Dec 31, 2008
Messages:
476
The chance to attack is multipicative, unfortunately. It is 0.5*0.25 percent chance to attack. That is why it is 37.5%. Of course, imagine how things would change if it was 25%... Togekiss...
25. ### General Tso

Joined:
Jun 2, 2007
Messages:
1,787
I just took a test on probability today and I thought it was out of my lifeeeeeee!!!!

Hax is part of the game, so what. You build your team so one hax shouldn't undo you.