Predicting luck by looking at the RNG

General feedback and discussion of the game.

Moderator: Forum Moderators

Post Reply
Higher Game
Posts: 171
Joined: August 16th, 2006, 1:01 am

Predicting luck by looking at the RNG

Post by Higher Game »

I've heard about how an RNG isn't truly "random", and that eventually patterns emerge. This is why RNGs can sometimes be called pseudorandom RNGs. This article explains how it works in the game Doom.

http://doom.wikia.com/wiki/Pseudorandom ... _generator

This is general information about RNGs.

http://en.wikipedia.org/wiki/Hardware_r ... _generator

Now, this got me thinking. Wesnoth is a turn based game, not an action game like Doom. Because of the free amount of time between turns, would it be possible to figure out what the RNG has planned ahead of time? Can this be used to cheat in multiplayer? I spectated a multiplayer match and saw one 4/4 hit and one 3/4 hit, on the same turn, on a water unit. That's really bad luck. Could it have been predicted?

Also, in some games I noticed the results are saved ahead of time. I once did save states in some SNES RPGS before I leveled, but found that the results were always the same! Of course, save/reloading works in Wesnoth. Is this for the best, and is there a way to change it? :)
silveroxide
Posts: 5
Joined: August 15th, 2006, 1:03 pm

Post by silveroxide »

Pseudorandom does not equal predictable. What you are suggesting would be equivalent to saying that because croupiers can't shuffle cards truly randomly, you could go to casinos and win every time.
Higher Game
Posts: 171
Joined: August 16th, 2006, 1:01 am

Post by Higher Game »

Yes, it's called card counting, and you can get thrown out for doing it. :D It's impossible for an average person to do it, and it's probably impossible to look at the RNG for the average person. But a super intelligent genius could probably do it.
silveroxide
Posts: 5
Joined: August 15th, 2006, 1:03 pm

Post by silveroxide »

Yes, I forgot that for some games they don't shuffle the deck. But I'm not talking about card counting, which anyway doesn't guarantee winning every time, just makes it more probable. I'm talking about just walking into a casino and being able to guess what cards you will be dealt first time. For comparison, this is how a deck is dealt in blackjack (and possibly other games):

*Shuffle*
*Deal*
*Deal*
*Deal*
...
*Shuffle*
*Deal*
*Deal*
*Deal*

Which means that you can remember which cards have already been dealt and discount them in calculating your expectations. In Wesnoth the equivalent would be

*Shuffle*
*Deal*
*Shuffle*
*Deal*
...

Which makes the equivalent of card counting impossible. Even if the shuffling wasn't perfectly random, you can't guess what cards you will get, and it's the same with Wesnoth.

(Actually, I have no idea what mechanism Wesnoth uses. I'm pointing out that even if some game used a psuedorandom generator, that does not mean you can predict the outcome)
zaimoni
Posts: 281
Joined: January 27th, 2005, 7:00 am
Location: Linn Valley, KS U.S.A.
Contact:

Post by zaimoni »

This has been discussed before. http://www.wesnoth.org/forum/viewtopic. ... hlight=rng

Theoretically, the problem is that while individual results may be unpredictable, a bad RNG may be highly correlated across a small interval...such as every other random number.

This is empirically not an issue with Windows (both MSVC and MingW use the RNG in msvcrt.dll, which has been tested throughly as part of arguing that post). It should not be an issue on *NIX thanks to the years of work on /dev/random.

Other platforms and compilers...no informed opinion, although I would hope anything recent would avoid the catastrophes of the 1960's that were still running around in the 1980's.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Well, isn't it so that the internal clock is used in any case when generating random numbers (as a seed or in some other way)? In that case, turn-basedness would have nothing to do with predicting what the RNG spits out. So no, you can't calculate what the RNG will spit out next unless you know exactly when the RNG is called on probably higher than millisecond precision.
Dave
Founding Developer
Posts: 7071
Joined: August 17th, 2003, 5:07 am
Location: Seattle
Contact:

Post by Dave »

Well, if you really wanted you could modify the source code of the game to tell you what it's planning to spit out next....or you could even tell it what you want the next 'random' number to be.

Actually predicting patterns from what is available in the default build though, would be quite difficult; at least without looking at save/replay files.

David
“At Gambling, the deadly sin is to mistake bad play for bad luck.” -- Ian Fleming
k3nn
Posts: 16
Joined: August 19th, 2006, 8:07 pm

Re: Predicting luck by looking at the RNG

Post by k3nn »

Higher Game wrote: I spectated a multiplayer match and saw one 4/4 hit and one 3/4 hit, on the same turn, on a water unit. That's really bad luck. Could it have been predicted?
It's been a wee while since I did maths. But assuming 'a water unit' means 'a unit sitting in water, with 20% armor' then I'm pretty sure the chance of being hit 7 times out of 8 is:

8 * [0.8]^7 * [0.2]^1 = 0.36.

So, it's actually fairly likely to get hit that much. </nerdiness>


On the other hand, you may have meant something different, in which case I retract everything I just said.
halleck
Posts: 229
Joined: October 12th, 2005, 3:47 pm

Post by halleck »

Welcome to the forums K3nn.
Screw it... I can go without a sig.
Sly
Posts: 258
Joined: October 10th, 2005, 11:59 am
Location: Montrouge (Fr, 92)
Contact:

Re: Predicting luck by looking at the RNG

Post by Sly »

Higher Game wrote:This is general information about RNGs.

http://en.wikipedia.org/wiki/Hardware_r ... _generator

Now, this got me thinking. Wesnoth is a turn based game, not an action game like Doom. Because of the free amount of time between turns, would it be possible to figure out what the RNG has planned ahead of time? Can this be used to cheat in multiplayer? I spectated a multiplayer match and saw one 4/4 hit and one 3/4 hit, on the same turn, on a water unit. That's really bad luck. Could it have been predicted?
Hum, how to say it ... either you're doing this on purpose either you did'nt read the link you posted :?
Wikipedia wrote:On the other hand, it has become relatively easy to produce pseudo-random number generators that are guaranteed not to repeat on any conceivable computer within a time-frame that is millions of times longer than the age of the universe.
Wich explicitely says that you could only predict the outcome of a attack if your current game session (since you last launched wesnoth) last about trillions of centuries :roll:
podunk
Posts: 93
Joined: June 9th, 2006, 12:03 pm

Post by podunk »

Speaking of random number generators and luck. Does the RNG determine unit traits - or are there limits or ranges that vary for every scene?

For instance, recruiting shaman. In HttT 1.1.8 The Elves Besieged scene - I have never gotten a shaman over 26 HP. I spent an hour the other day recruiting and starting over trying to get a shaman I liked before giving up and went on with a 24 HP shaman. So what I've started doing is only recruit 1 shaman at the start and once I get to IoA I recruit another - which is almost always 30+ (only once since i started paying attention did I get less than a 30 there, and it was a 28. )

Scouts is another example I've noticed. The highest hit point scout I've gotten since I noticed this is 33 - *until* you get to The Princess scenario - where you consistently get 35 to 39 HP scouts.

In the Bay of Pearls is another example - fighters and horsemen you recruit here are much higher hit point units than you will get in IoA or Blackwater Port so I always try to stock up on future tanks here.

So I guess what I'm asking here is are traits shaded or the ranges adjusted for every scenario, and if so where can I find the modification chart?
Soliton
Site Administrator
Posts: 1686
Joined: April 5th, 2005, 3:25 pm
Location: #wesnoth-mp

Post by Soliton »

podunk wrote: For instance, recruiting shaman. In HttT 1.1.8 The Elves Besieged scene - I have never gotten a shaman over 26 HP. I spent an hour the other day recruiting and starting over trying to get a shaman I liked before giving up and went on with a 24 HP shaman.
There is a patch to undo any recruitment in singleplayer, maybe that helps your paranoia. (and makes playing campaigns more fun for you) :P
"If gameplay requires it, they can be made to live on Venus." -- scott
podunk
Posts: 93
Joined: June 9th, 2006, 12:03 pm

Post by podunk »

I don't want to change anything really. I mean strategy is taking the events that are and winning rather that trying to make what is isn't or vice versa.

Before I spent that hour I'd already gotten in the habit of recruiting ahead and leveling later according to the scene I'm on. For instance I recruit extra mages in IoA because you have a much better chance (I think) of getting a fast and resilient mage. I recruit extra scouts in PoW - level a couple there and save the others to level in Northern Winter. My goal is to have 3 high HP level 3 scouts (Outriders) for test of the clans.

I was just wondering if this was a valid pattern or the product of a "fevered imagination" . :-)
Dacyn
Posts: 1855
Joined: May 1st, 2004, 9:34 am
Location: Texas

Post by Dacyn »

It's a product of your imagination.
Post Reply