How probable is extreme (un)luck? A mathematical study

Share and discuss strategies for playing the game, and get help and tips from other players.

Moderator: Forum Moderators

Post Reply
dwarftough
Posts: 628
Joined: August 4th, 2019, 5:27 pm
Contact:

How probable is extreme (un)luck? A mathematical study

Post by dwarftough »

After a game you often see chatlines like "I was soo unlucky, -20% inflicted" or "he was too lucky, +10% over the whole game" and so on, and so on. Luck in Wesnoth is a never-ending source of emotional comments. And at some point, the question arose in my head: How much luck/unluck is really too much?

In this study I'll consider the most obvious metric of luck in Wesnoth (with Standard RNG): percentages of inflicted/taken strikes in the "Statistics" menu (highlighted by red).
The statistics we discuss highlighted in red
The statistics we discuss highlighted in red
hits.png (41.65 KiB) Viewed 1418 times
I will use a simple model to get reasonable estimates on the probabilities and luck ranges: each real game is a lot more complex but these numbers should at least give you some idea of how it can go.

This forum post is a summary of my results. The full article is presented in an attached pdf and will consist of several parts: basic model and results, discussion and some extra info, and detailed calculations that give the results.

Main Result: Probable luck ranges for units on 50% defense
That would be our simplified model: suppose we have only units fighting on 50% defense (for example, Orcish Grunts on hills). We want to estimate which percents in the stats window (for strikes) we'll see with the probability of, let say, 95%. We also suppose, for simplicity of calculation, that the number of strikes n is enough large. Here is the result:
Main result formula
Main result formula
200 and 95% are easy to remember numbers, but there isn't anything magical about 95%: a similar formula can be derived for other probabilities. For 98% the formula's numerator is 233, for 99% it's 257. Below is the table with some precalculated results for different probabilities and numbers of strikes n.
Table of precalculated probable ranges
Table of precalculated probable ranges
Снимок экрана от 2025-09-27 04-48-43.png (16.4 KiB) Viewed 1418 times
Some conclusions

What are some brief conclusions we can derive from these results and what do I have to say about this?

1. The possible percentage range gets narrower when n rises, but at a slower pace

As you can see from the table, ±20% strikes luck range is achieved (with 95% probability) only at n = 100 strikes (which is a long enough game). And ±10% is reached only at n = 400 strikes (that's an excruciatingly long game)

Don't forget that it's the range that occurs with 95% probability, here goes the second conclusion (let's take n = 100 for example)

2. For n = 100 roughly 1 of 20 games will face more than 20% stats, roughly 1 of 50 games will face more than 23.3%, roughly 1 of 100 games will face more than 25.7%

As small as it may seem, 1% isn't that small probability and such games will appear once in a while. And this 25.7% range is calculated for long enough games (n = 100), if the game is shorter, the range may be bigger than that.
Attachments
dwarftoughExtremeLuckStudy.pdf
Full text
(135.87 KiB) Downloaded 37 times
Last edited by dwarftough on September 27th, 2025, 12:23 pm, edited 1 time in total.
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
MP versions of classical mainline campaigns: UtBS, TRoW, SotA
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Biased RNG in MP
the_kaygan
Posts: 6
Joined: June 13th, 2017, 7:53 pm

Re: How probable is extreme (un)luck? A mathematical study

Post by the_kaygan »

kCHkJ9CelXLfixD89ACs-ZQzQCle5XtU-lRIOZPqPMZz8b6A9GCeoLwgTH0t-ynizbJPAmv48pbCa6uzz2vNAfn2.jpg
Vilebeggar
Posts: 197
Joined: September 5th, 2018, 5:21 pm
Location: Albania

Re: How probable is extreme (un)luck? A mathematical study

Post by Vilebeggar »

Calculations aside i want to talk how bad rolls affect a competitive game. If you are generally unlucky in a game that will negatively affect your chances of winning since your units wont be able to hit/dodge. But what is worse in my opinion in unluck in KEY moments, like failing to kill a unit on an important chokehold or an important unit of yours dying despite being on favourable terrain.

It is known that a match between a superior player and an inferior one will most likely result in the superior players victory. However due to the rng and faction matchup factor anyone can beat any player at least once in a wesnoth game. Sometime extreme unluck is enough to settle a game. However a game between 2 even players in my opinion will most likely be decided by the rng or the faction matchup which has been a longstanding issue that frankly cannot be fixed since this game has 6 of them and multiple different maps.

Though some matchups like for example a loyalist vs dwarf or undead vs drake have always been problematic and on certain maps have been borderline unplayable despite the rng. Many attempts have been made by some parties (namely the ladder era guys) to fix the balance issues between factions for a spam of over 20 years that somehow are still considered a work "in progress". New patches of updates are still released frequently that only further mish mash the unit pool and widen the inbalance. To me they are only trying to hide the fact that they have failed.

So yes i would say wesnoth is an imperfect game where luck or the matchup type will get the best of you sometimes but you must play it with a grain of salt.
newbieA
Posts: 32
Joined: November 21st, 2023, 11:09 pm

Re: How probable is extreme (un)luck? A mathematical study

Post by newbieA »

Hmm maybe in even games yeah, critical rng will decide games..
How about make timing pushes and respect ToD. Surely the -25% whatever would boost survivability a lot... And +25% will increase chance to kill by a lot...
Tonepoet
Posts: 185
Joined: November 18th, 2005, 2:54 pm
Contact:

Re: How probable is extreme (un)luck? A mathematical study

Post by Tonepoet »

Luck isn't all math, mind you. Some of it is timing. Good luck on a crucial turm is more important than bad luck throughout an entire game. Grig the Goblin basically turned around a game of Clash for me by successfully dodging Mage blows when I was just about to lose if I recall correctly. It was a glorious comeback, as he lead Goblins down the other side of the battlefield.
Htonsew Rof Elttab Eht is just too cool for school. I've got no words to describe it. Have any of you guys tried it? ;-)
dwarftough
Posts: 628
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: How probable is extreme (un)luck? A mathematical study

Post by dwarftough »

Tonepoet wrote: June 15th, 2026, 4:00 pm Luck isn't all math, mind you. Some of it is timing. Good luck on a crucial turm is more important than bad luck throughout an entire game. Grig the Goblin basically turned around a game of Clash for me by successfully dodging Mage blows when I was just about to lose if I recall correctly. It was a glorious comeback, as he lead Goblins down the other side of the battlefield.
That's true, luck in critical moments is more important than the overall luck. Note, however, that you may use this same method to look at a critical moment itself, and as the critical moment is by definition short, the range of possible luck or unluck in it is wide.
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
MP versions of classical mainline campaigns: UtBS, TRoW, SotA
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Biased RNG in MP
dwarftough
Posts: 628
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: How probable is extreme (un)luck? A mathematical study

Post by dwarftough »

newbieA wrote: June 14th, 2026, 10:58 pm Hmm maybe in even games yeah, critical rng will decide games..
How about make timing pushes and respect ToD. Surely the -25% whatever would boost survivability a lot... And +25% will increase chance to kill by a lot...
There are a lot of things that decide games. Strictly speaking, the Wesnoth game isn't a row of indepedent trials because the results of previous fights open or close possibilities for future fights (in two ways, a player may decide to do/not to do something base on the outcome, and the outcome may eliminate any chance for something entirely, let say you either kill a guard and may try a leaderkill after that, or you don't and the leaderkill is impossible)

I'm still thinking about what models could be used to evaluate more things about the game, this is really the first step. And I don't think it's justified to declare Wesnoth the game of chance right from it, but the first attempt to evaluate actual numbers, what's lucky and what's unlucky, showed that the ranges of possible luck are wider than one might think
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
MP versions of classical mainline campaigns: UtBS, TRoW, SotA
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Biased RNG in MP
mctom
Posts: 33
Joined: June 7th, 2025, 2:44 pm
Location: Gdańsk, Poland

Re: How probable is extreme (un)luck? A mathematical study

Post by mctom »

I think Wesnoth is a perfect platform to demonstrate the butterfly effect - pit two AIs against each other, save the game once they encounter each other in the battle, then reload it twice and observe the effects of different randomness seeds. Even though AIs are completely deterministic (I assume), I suspect the games will diverge completely after a few more turns.

An approach known from quantum physics could be used - most popularly known as Schrödinger's cat which is partially alive until the box is open. With this approach unit's HP would not be numbers but functions: probability density of their HP. Each unit would start with a 100% probability of having maximum HP, which over time would be modified by battling other units, with their own HP probability curves. If the model is well constructed, and the "duel function" precise enough, this framework would allow predicting the outcomes of the series of duels between many units, and in a greater perspective, the entire games.

Now to make it actually useful, in such model no units would ever die - even if the entire HP distribution goes below 0. However the model would assign no effect to these units, or perhaps even boost the HP of the other combatant, since a lack of unit to fight against is an advantage (no loss of movement for example).
Such model would benefit from being linear, thus the entire algebraic toolbox could be used to estimate more complex scenarios.

Chances may be modeled, but nobody doubts that skill is a major factor in winning a game to begin with. That's why math was never proven useful in balancing factions.
Managing randomness and uncertainty is a part of the strategy - a well known fact for those who have spent enough time in real life. :)
PreposterousChicken
Posts: 2
Joined: July 2nd, 2026, 2:00 pm

Re: How probable is extreme (un)luck? A mathematical study

Post by PreposterousChicken »

So what you could theoretically do, I am putting it out there despite there are practical flaws unfortunately in the concept, is try and measure variance in impact of specific combat's result on game result. And compare that with correlation between basic "luck" as measure of hits/damages/kills and game result.

If the variance is small and correlation is high, that would suggest that tested game* is decided more by army size and luck than strategic choices. On the other side of the spectrum there'd be high variance in importance of instances of combat, basically we could detect (theoretically) key combats existence, and correlation between luck and result should be weakened, especially if we cut off luck-outliers.

Now, I marked word game with asterisk, because what we really could study is a combination of game and player(s). Which is very important if the players are automatons, because they are prone to rely more on large scale computation and less on conceptual strategy. This can skew results toward "shallow game".

Another problem is how do we actually study that. For each combat to check it's statistical impact on game result we'd need to play the game out from that point numerous times. Exploring the resultant tree of possibilities is madness, so we'd need to sample combats randomly and that introduces many methodological questions, mostly: how to ensure sample is representative of anything true about the game?
mgwest
Posts: 1
Joined: July 27th, 2026, 9:21 pm

Re: How probable is extreme (un)luck? A mathematical study

Post by mgwest »

dwarftough's ±200/√n is a large-n result — it leans on the normal approximation, which is the right tool for a whole game's worth of strikes. It's worth spelling out what it implies for the point you made to Tonepoet, though: that a critical moment is short and therefore wide. At small n the distribution doesn't merely get wider, it stops being bell-shaped at all.

Concrete case. First watch, my Grunt is down to 18 HP, there is an Elvish Fighter on 11 HP sitting in forest, and I want the kill.

The elf's HP after my attack:
  • 0 HP — 64%dwarftough's ±200/√n is a large-n result — it leans on the normal approximation, which is the right tool for a whole game's worth of strikes. It's worth spelling out what it implies for the point you made to Tonepoet, though: that a critical moment is short and therefore wide. At small n the distribution doesn't merely get wider, it stops being bell-shaped at all.

    Concrete case. First watch, my Grunt is down to 18 HP, there is an Elvish Fighter on 11 HP sitting in forest, and I want the kill.

    The elf's HP after my attack:
    • 0 HP — 64%
    • 11 HP — 36%
    That is the whole distribution. Two outcomes, nothing in between. The Grunt swings for 11 at night and the elf is on 11, so any strike that connects is lethal and any miss leaves it completely untouched. Expected damage is 7.04, and 7.04 is a number this fight cannot produce.

    The counterattack is the side I actually care about:
    • Grunt untouched — 50.5%
    • Grunt dead — 4.7%
    That 4.7% is 0.36 × 0.6^4: the elf has to survive both my swings and then land all four of its own. Which is exactly the shape of the thing that gets remembered afterwards as "I was so unlucky" — it isn't the tail of a bell curve, it's a specific conjunction you can write down.

    mctom, your HP-as-probability-density framing is the right one for this, and you don't have to approximate it. A single exchange is an exact discrete convolution over the strike order, and the state space is small enough to just enumerate. Where it turns hard is the series-of-duels case you go on to describe, because once a unit can die the fights stop being independent.

    I built a Wesnoth damage calculator that does the single-fight case — full HP distribution for both sides, chance to kill, chance to die, and what the exchange costs in gold. Here is the exchange above in it. Disclosure: it's mine. The data is pinned to 1.18 stable, so if you're playing the 1.19 dev branch some unit stats won't match.
  • 11 HP — 36%
That is the whole distribution. Two outcomes, nothing in between. The Grunt swings for 11 at night and the elf is on 11, so any strike that connects is lethal and any miss leaves it completely untouched. Expected damage is 7.04, and 7.04 is a number this fight cannot produce.

The counterattack is the side I actually care about:
  • Grunt untouched — 50.5%
  • Grunt dead — 4.7%
That 4.7% is 0.36 × 0.6^4: the elf has to survive both my swings and then land all four of its own. Which is exactly the shape of the thing that gets remembered afterwards as "I was so unlucky" — it isn't the tail of a bell curve, it's a specific conjunction you can write down.

mctom, your HP-as-probability-density framing is the right one for this, and you don't have to approximate it. A single exchange is an exact discrete convolution over the strike order, and the state space is small enough to just enumerate. Where it turns hard is the series-of-duels case you go on to describe, because once a unit can die the fights stop being independent.

I built a Wesnoth damage calculator that does the single-fight case — full HP distribution for both sides, chance to kill, chance to die, and what the exchange costs in gold. Here is the exchange above in it. Disclosure: it's mine. The data is pinned to 1.18 stable, so if you're playing the 1.19 dev branch some unit stats won't match.
dwarftough
Posts: 628
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: How probable is extreme (un)luck? A mathematical study

Post by dwarftough »

mctom wrote: June 22nd, 2026, 6:37 am Even though AIs are completely deterministic (I assume)
I don't think so actually, AI recruits randomly for sure, and that alone is enough for it to be non-deterministic even if it caclulates the moves deterministically. Although games indeed diverge very quickly: starting with units getting random traits.
mctom wrote: June 22nd, 2026, 6:37 am With this approach unit's HP would not be numbers but functions: probability density of their HP. Each unit would start with a 100% probability of having maximum HP, which over time would be modified by battling other units, with their own HP probability curves.
If the model is well constructed, and the "duel function" precise enough, this framework would allow predicting the outcomes of the series of duels between many units, and in a greater perspective, the entire games.
The thing that puzzles me still with such an approach is how you incorporate players' choices in it. If Wesnoth were a system that just evolves by the certain rules, it would be easy, but for players making choices depending on the outcome it's hard because we don't have any approximate formal idea how they make this choice. Aside from it looks interesting: either this model, or calculating all variations with weighting them by probabilities (that one is bound to exponentially explode ofc).
mgwest wrote: August 6th, 2026, 9:08 pm single exchange is an exact discrete convolution over the strike order, and the state space is small enough to just enumerate
There is a table for small n's in the pdf: I've calculated a bunch. The main result is indeed for a large n which is explicitly mentioned.
Co-founder and current maintainer of IsarFoundation, Afterlife Rated and overall Wesnoth Autohost Project
MP versions of classical mainline campaigns: UtBS, TRoW, SotA
Developer and maintainer of my fork of World Conquest, Invincibles Conquest II
Biased RNG in MP
yaficev
Posts: 1
Joined: August 20th, 2026, 10:17 am

Re: How probable is extreme (un)luck? A mathematical study

Post by yaficev »

dwarftough wrote: August 13th, 2026, 1:33 pmstarting with units getting random traits.
Indeed, traits matter a lot in this game and not getting desirable ones at the beginning can be frustrating.

I personally like to reduce the effect of the RNG by focusing a lot on deterministic survival - always having at least 1 HP more than what the current threat environment can output.

Such a strategy can depend a lot on traits. For example, 2x Strong Spearmen at night can output up to 36 damage. To survive that, you need at least 37 HP. An Elvish Fighter can get that if it's Resilient Non-Quick, but not by any other trait combo. Resilient Quick is 1 HP short.

From some research, I've found that 49 HP is a highly desirable breakpoint for a level 2 or 3 unit, especially a ranged one. This leads to some interesting outcomes for campaign. For example, normally you wouldn't consider Strong Intelligent as a good trait combo for a Silver Mage. But consider that a Silver Mage has 48 HP, and Strong gets you just enough for 49 HP. It's enough to survive any of the following:
  • 2x Strong Orcish Grunts at night
  • 2x Strong Orcish Warriors at day
  • 2x Revenants at day
  • 2x Strong Spearmen at dawn/dusk
What breakpoints are relevant depends on who you're fighting and what you're defending with. In the case of Elvish Fighter/Hero/Champion vs. Spearman/Swordsman/Royal Guard, the breakpoints are 37 HP, 57 HP, and 73 HP. The first two are achievable at the same level only with Resilient Non-Quick. The third can be met also with Resilient Quick. It follows that:
  • If at level parity, only engage at favorable time of day to preserve deterministic survival.
  • If one level above, you can engage also at dawn/dusk.
Notice that 37 and 73 are prime numbers, and that's not a coincidence of course. Having 1 HP more than a fairly composite number often results in a prime number.

A somewhat more advanced development of this concept is what happens when you attack a ranged unit with a melee unit but expect counterattacks from melee units the next turn. So for example an Elvish Fighter attacking a Strong Orcish Archer at day but getting attacked by 2x Strong Grunts the next turn (also at day). The analysis:

Orcish Archer is 3x2 melee
Strong is 4x2
At Day is 3x2 = 6
2x Strong Grunts at day = 28
Need 35 HP to survive

35 HP can be met by Resilient + any other trait. Fighting Orcs is a bit more forgiving on traits because of their relatively low minimum damage output.

But when fighting more damaging factions like Loyalists, traits matter more and it is thus more frustrating if you don't get what you want.
Post Reply