Biased RNG in MP

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

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

Biased RNG in MP

Post by dwarftough »

Since 1.16 the Biased RNG has been available in SP. It makes the outcomes of battles follow the expected value much more closely drastically reducing the variance. Choosing a different RNG is not supported in Multiplayer, so this mod tries to emulate the Biased RNG behaviour.

It's almost certainly incompatible with Advanced Wesnoth Wars and it's very possible more addons incompatible with this. Make sure to leave bugreports here!

Summary how it works: it calculates the expected value, which is EV = strikes * chance to hit. If it's an integer, the unit hits exactly EV times. If it has a fractional part, then the unit hits floor(EV) times and may make one extra hit with probability fractional_part(EV). The order of hits and misses is still random. For example: Mage has 3 attacks with 70% to hit. EV = 3 * 0.7 = 2.1. So Mage will hit two times surely and with probability 10% one more time.
Снимок экрана от 2025-07-21 23-24-24.png
Снимок экрана от 2025-07-21 23-24-24.png (12.82 KiB) Viewed 1736 times
Special thanks to celticminstrel and Ravana for their great help in Wesnoth's #modding channel that made this mod possible.
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
User avatar
Ravana
Forum Moderator
Posts: 3422
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Biased RNG in MP

Post by Ravana »

Code looks like it should work but icon.png and icon.xcf look unused.
dwarftough
Posts: 623
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: Biased RNG in MP

Post by dwarftough »

Ravana wrote: July 21st, 2025, 7:30 pm Code looks like it should work but icon.png and icon.xcf look unused.
Yeah, that's just for the add-on picture in server.pbl tbh
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: 623
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: Biased RNG in MP

Post by dwarftough »

The funny thing with this mod is that it makes the stats window to show always 0
clearrnd.jpg
clearrnd.jpg (34.45 KiB) Viewed 1694 times
It's clear why: the mod alters the hit chances to either 100 or 0 during the attack, so from the engine standpoint there is no variance at all. Essentially it's not true: there may be variance about making that extra hit or not. But this calculation is hidden inside the mod and so doesn't count.

If it's possible to make an ability that sets the hit chance equal to the value of a variable, this stats thing may be solved: instead of 0 or 100 hit chances the mod would generate either 0, 100 or some value in-between.
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
L29Ah
Posts: 6
Joined: June 4th, 2020, 6:27 pm

Re: Biased RNG in MP

Post by L29Ah »

The expected battle outcomes in that pre-battle window are off now. Otherwise it works great, thanks for your work.
dwarftough
Posts: 623
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: Biased RNG in MP

Post by dwarftough »

L29Ah wrote: August 6th, 2025, 7:08 pm The expected battle outcomes in that pre-battle window are off now. Otherwise it works great, thanks for your work.
Unlike the stats window, this can't be helped. The pre-battle calculator is nonadjustable by modifications. Funny enough, it doesn't even change for SP with in-game Biased RNG.
L29Ah wrote: August 6th, 2025, 7:08 pm thanks for your work.
Glad you liked it!
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: 623
Joined: August 4th, 2019, 5:27 pm
Contact:

Re: Biased RNG in MP

Post by dwarftough »

Version 1.1.0 has been released!
Без имени.png
Без имени.png (15.7 KiB) Viewed 1409 times
Снимок экрана от 2025-09-18 02-24-01.png
Снимок экрана от 2025-09-18 02-24-01.png (39.78 KiB) Viewed 1409 times
It fixes one thing but a very big thing: the statistics windows now should show actual data.
Снимок экрана от 2025-09-18 02-17-58.png
Снимок экрана от 2025-09-18 02-17-58.png (51.38 KiB) Viewed 1409 times
Special thanks to gfgtdf for mentioning self.wml_vars, without it the fix wouldn't be possible.
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
Post Reply