# Are the to-hit chances skewed in Wesnoth single-player?

I'm just learning Battle for Wesnoth in single-player mode, playing the first and second single-player campaigns (I won the 4-scenario brothers campaign, and am on scenario 4 of the 23-scenario Konrad campaign, on Normal difficulty), and I feel like I am either having a lot of bad luck, or there is some skewing or stickiness in the to-hit chances.

As in, I often have archers take 4 shots at 60% and they miss 3 or 4 of them. And I have lost several units when the enemy gets 3-4 hits in a row on a healthy unit.

Does "Normal" difficulty skew the to-hit odds to silently favor the AI, or am I just noticing when I have bad luck?

• I am not a dev nor have I looked at the code, so I cannot answer this question with any authority but it is highly unlikely that anything like this is in there. Single player difficulty is tweaked with gold and turn limits, not cheating at dice. The human brain is notoriously bad at accurately estimating probabilities. Mathematically, if you have archers take 4 shots at 60% chance to hit, you are going to be rather disappointed roughly 1/5 (18%) of the time (i.e. they miss 3-4 shots), which may be more often than you would expect. – jw013 Apr 23 '15 at 22:50
• This is a pretty good answer, especially if no one knows&says otherwise. I asked because some games do things like tweak odds by difficulty, and I figured if someone knew, they'd ask. Judging by the openness and simplicity of the to-hit chances, and the feature to show odds, I think you are right. I just keep being surprised, to the detriment of my troops. ;-( – Dronz Apr 24 '15 at 5:07
• I dunno though. I am playing some more, and sure feel like I am getting screwed. Even when I have 60-70% defense, I am getting hit most of the time, while my 70% magic attacks are missing repeatedly, etc. Ah well. If I'm getting a karmic backlash, this game is a decent place to take it. – Dronz Apr 24 '15 at 5:53

A quick look at the source code reveals no evidence of bias. The key lines appear to be (from src/actions/attack.cpp):

bool attack::perform hit(bool attacker_turn, statistics::attack_context &stats)
{
int ran_num = random_new::generator->next_random();
bool hits = (ran_num % 100) < attacker.cth_;


In plain English, when calculating what happens in an attack, it generates a random number between 0 and 99 inclusive, and if that number is less than the attacker's chance to hit, the attack hits.

Chasing through the code, random_new::generator->next_random() is simply a wrapper around the C standard library's random-number generator. This generator has its faults, but a bias in favor of streaks of similar outcomes isn't one of them.

In short, you're experiencing a very human tendency to see streaks of similar outcomes as "not random", when in fact they're a perfectly normal result of randomness. Next time you make an attack, click the "damage calculations" button and look at the full range of possible outcomes and their odds.