Dice app on vassel

By Greedyfly, in X-Wing

So a question I have about a rng or dice app, as I don't real know or yet to understand ( would like if possible to have an answer in as plain or laymans terms ) the computer side of things is, being a program which is by its nature ordered so it can even perform its function as a program, what makes its random. It's a set program right, how does it chose what comes up on a dice app as its not physically rolling the dice.

I have heard the term random get thrown around like its going out of fashion and for most things that people use the word for those things are certainly not random eg an advertisement was random ( no lots of time and research and decision making went it said advert) , joe blogs came out with the most random thing at work ( no they were thinking about what they said that's why they said it even if it was out of context of the work environment) so basically what actually makes these pre programmed programs random?

@Greedyfly: a pseudorandom number generator is a mathematical algorithm that accepts some initial value (a "seed") and, based on that initial value, computes a very large set of output values that look random. The procedures are usually very complicated, but the best ones produce values that are indistinguishable from "true" random numbers.

That doesn't actually help much if you ask me.

It only helps if your RNG is likely to generate the same number multiple times (once it rolls a 4, it's more likely to roll another 4). It doesn't help if, after the RNG rolls a 4, it's more likely to roll a 6. And both of those cases are problematic.

Basically, streaking (getting multiples of the same result in a row) is a specific instance of the more generic problem of having previous results affect future results.

I let Theorist implement that change mostly to address the issue of Vassal dice perception, which was becoming quite negative over at Team Covenant around the end of 2013.

That doesn't actually help much if you ask me.

It only helps if your RNG is likely to generate the same number multiple times (once it rolls a 4, it's more likely to roll another 4). It doesn't help if, after the RNG rolls a 4, it's more likely to roll a 6. And both of those cases are problematic.

Basically, streaking (getting multiples of the same result in a row) is a specific instance of the more generic problem of having previous results affect future results.

I let Theorist implement that change mostly to address the issue of Vassal dice perception, which was becoming quite negative over at Team Covenant around the end of 2013.

It almost certainly didn't accomplish anything on the software side, but it didn't hurt anything either, and it made a lot of nervous people feel more comfortable that at least something was being done.

I let Theorist implement that change mostly to address the issue of Vassal dice perception, which was becoming quite negative over at Team Covenant around the end of 2013.

Yeah, I remember seeing some people complain about streaking dice, and the change seemed to calm their worries.

It's just that it did nothing to "increase randomness", as ransburger seemed to imply :P

In any case, assuming there is actually a problem with VASSAL's RNG (which I highly doubt), other than reworking VASSAL's source code, I don't think there's much that can be done in the X-Wing module to fix the problem. I'd much rather you work on adding newer, better features than muck around with the RNG.

I did a basic analysis to see what deviation vs expected is. Green evades and red hits seem a little high. Maybe the dupes are to blame...

EDIT: duh, I'm including conversions. One moment...

16891251926_01971e4a29_o.png

Edited by sozin

I did a basic analysis to see what deviation vs expected is. Green evades and red hits seem a little high. Maybe the dupes are to blame...

Did you ignore any and all conversions from focus tokens and other effects?

There we go, as expected:

16729631328_46e2b1661f_b.jpg

Edited by sozin

BIG DATA

There we go, as expected...

This might be getting too arcane for most people here to care about, but it's really easy to see that the green dice are fine: a chi-squared goodness-of-fit test yields a test statistic that's very far from meeting the usual 0.05 significance level.

When the same test is applied to the red dice, though, it actually comes out as statistically significant. But that's a good lesson in why the most obvious test isn't always the right one: with 186,000+ observations here, the chi-squared test is really sensitive. So Pearson's chi-squared isn't actually a very good indicator, here: it tells us whether the observed and expected distributions are different, but it's not very good at telling how different they are.

If we use Cramer's V instead, which (speaking very generally) "corrects" for the large sample size, both the green and red dice are okay.

The very best test would be a Monte Carlo-style simulation where you generated a very large number of data sets of about the same size, plotted Pearson's chi-squared for all of them, and then located the actual observed data set in that distribution. I haven't done that (and probably won't), but I'm pretty confident it would also show that Vassal's dice are performing well in the aggregate.

There we go, as expected...

This might be getting too arcane for most people here to care about, but it's really easy to see that the green dice are fine: a chi-squared goodness-of-fit test yields a test statistic that's very far from meeting the usual 0.05 significance level.

When the same test is applied to the red dice, though, it actually comes out as statistically significant. But that's a good lesson in why the most obvious test isn't always the right one: with 186,000+ observations here, the chi-squared test is really sensitive. So Pearson's chi-squared isn't actually a very good indicator, here: it tells us whether the observed and expected distributions are different, but it's not very good at telling how different they are.

If we use Cramer's V instead, which (speaking very generally) "corrects" for the large sample size, both the green and red dice are okay.

The very best test would be a Monte Carlo-style simulation where you generated a very large number of data sets of about the same size, plotted Pearson's chi-squared for all of them, and then located the actual observed data set in that distribution. I haven't done that (and probably won't), but I'm pretty confident it would also show that Vassal's dice are performing well in the aggregate.

Can you do all the stats for my prelims for me? I'd make you cookies.

Can you do all the stats for my prelims for me? I'd make you cookies.

I am a sucker for cookies, but I have a full-time job, a toddler at home, and a dissertation of my own to finish. :unsure: If you're ever really stuck, though, send me a PM and I'll do my best to get you un-stuck.

Edited by Vorpal Sword

This has been debated so many times. Yet new players to vassal seem to pick this up. I feel the dice are streaky. Why I feel this is. I get way more crit rolls on vassal then in real life. It seems like I get 20% or higher crits on vassal. Now I may get a game or two in real life like that once a month. On vassal its just about every game. Then the evade dice. Seems that focus comes up more then not. If you play on vassal always go focus for defense then evade token. Seems to pay out every time. Not to knock those who worked on vassal. They've done an amazing job over the years.

I've tested the dice out. Yes after you roll 100 dice it may average out. I think the issue is the "seed". Because the seed is based of the internal clock. And if a program is making a "call" as to do the same command as get a random number with in mila seconds of each call. I think if a "break" a pause was created in between the calls. And even the breaks could be randomized. This could give a more random result.

And for something that is completely free. Its an amazing tool to practice on and get to meet new people from around the world. Except when you only roll 5 hits out of 30 attack dice and don't roll 1 single evade then snap you keyboard in half.

This has been debated so many times. Yet new players to vassal seem to pick this up. I feel the dice are streaky. Why I feel this is. I get way more crit rolls on vassal then in real life. It seems like I get 20% or higher crits on vassal. Now I may get a game or two in real life like that once a month. On vassal its just about every game. Then the evade dice. Seems that focus comes up more then not. If you play on vassal always go focus for defense then evade token. Seems to pay out every time. Not to knock those who worked on vassal. They've done an amazing job over the years.

I've tested the dice out. Yes after you roll 100 dice it may average out. I think the issue is the "seed". Because the seed is based of the internal clock. And if a program is making a "call" as to do the same command as get a random number with in mila seconds of each call. I think if a "break" a pause was created in between the calls. And even the breaks could be randomized. This could give a more random result.

And for something that is completely free. Its an amazing tool to practice on and get to meet new people from around the world. Except when you only roll 5 hits out of 30 attack dice and don't roll 1 single evade then snap you keyboard in half.

One of the tests I did on Vassal's dice roller was to look for correlations between adjacent rolls (that is, whether it's a "streaky" generator) and to look for average streak length. Even over the short term, its behavior was appropriate.

Also, the Vassal source code uses java.security.SecureRandom for dice calls, so finding streaks in an implementation would be a really big problem.

Unrelated (again): Vorpal, did you wind up with a store championship dice bag?

I feel the dice are streaky. Why I feel this is. I get way more crit rolls on vassal then in real life. It seems like I get 20% or higher crits on vassal. Now I may get a game or two in real life like that once a month. On vassal its just about every game. Then the evade dice. Seems that focus comes up more then not. If you play on vassal always go focus for defense then evade token. Seems to pay out every time.

What you're describing here isn't a streaking problem, but a distribution problem. And that kind of issue has been conclusively ruled out multiple times by multiple people.

I think the issue is the "seed". Because the seed is based of the internal clock. And if a program is making a "call" as to do the same command as get a random number with in mila seconds of each call. I think if a "break" a pause was created in between the calls. And even the breaks could be randomized. This could give a more random result.

If Vassal is seeding a new instance of SecureRandom every time it rolls a die, that would be poor coding practice and could lead to some issues for the operating system, but not the kind you're talking about. And because it's Object Oriented Programming 101 not to be sloppy about things like that, I imagine Vassal seeds the RNG just once, when it starts.

Unrelated (again): Vorpal, did you wind up with a store championship dice bag?

:(

Went twice, and both times had a few good rounds followed by a round of unbelievably, self-sabotagingly bad play.

I get way more crit rolls on vassal then in real life. It seems like I get 20% or higher crits on vassal.

Seems that focus comes up more then not.

This is only an impression you have and is not reflected in the data sozin posted previously.

I think the issue is the "seed". Because the seed is based of the internal clock. And if a program is making a "call" as to do the same command as get a random number with in mila seconds of each call. I think if a "break" a pause was created in between the calls. And even the breaks could be randomized. This could give a more random result.

I'm not sure you understand how a seed works for a random number generator. Your random number generator is seeded once. Once it's seeded, you have it generate a new random number whenever you need one. You do not re-seed it every time. The timing between your calls has no impact on the numbers generated.

Looking through VASSAL's code very briefly, it uses java.security.SecureRandom to generate a single global random number generator, which is used for all RNG needs throughout.

The doc for java.security.SecureRandom says the following:

This class provides a cryptographically strong random number generator (RNG).

A cryptographically strong random number minimally complies with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, section 4.9.1. Additionally, SecureRandom must produce non-deterministic output. Therefore any seed material passed to a SecureRandom object must be unpredictable, and all SecureRandom output sequences must be cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security.

If Vassal is seeding a new instance of SecureRandom every time it rolls a die, that would be poor coding practice and could lead to some issues for the operating system, but not the kind you're talking about. And because it's Object Oriented Programming 101 not to be sloppy about things like that, I imagine Vassal seeds the RNG just once, when it starts.

I don't think VASSAL is creating a new instance of SecureRandom every time.

Looking at GameModule.java:

  protected Random RNG = new SecureRandom();
  /**
   * @return a single Random number generator that all objects may share
   */
  public Random getRNG() {
    return RNG;
  }

Correct. That GameModule is an abstract singleton base class and is only instantiated once, on application startup.

<codesnob>Really nasty bit of design work there</codesnob>

Randomness does not mean the absence of streakiness on the short term. A game lets you roll about 30-90 attack dice and relatively less defense dice (if you average all factions, I think). It's more than possible to find important streaks in 1 game. In 10 games. In 400 games. It still doesn't mean it's not properly random.

We all haven't played the game that long (a few years top). We've all rolled collectively a lot less than trillions of dice rolls. It's very possible that in our short play window, the streaks have happened for YOU. It still isn't sufficient to call the system unfair and unrandom.

The system can't be changed from its current state to make any single user's experience "fair" without affecting its "random quality".

Randomness does not mean the absence of streakiness on the short term. A game lets you roll about 30-90 attack dice and relatively less defense dice (if you average all factions, I think). It's more than possible to find important streaks in 1 game. In 10 games. In 400 games. It still doesn't mean it's not properly random.

Just to emphasize a point here, you have to find some streaks over short sets of rolls. The complete absence of streaks would indicate that rolls were not random.

Edited by Vorpal Sword

Again this is a old debate. I've changed the sides of the dice to numbers. And ran several different tests myself not showing any big streaks. The fact that a clear dice option was added I think was great. I know the basics of programming. Have created several apps for fun. I've seen programs give the same return result because something didn't get cleared. I dug around in vassal program as much as I know how. Could not find any issues.

Maybe if we also added like dice option to the program. Like each side has a different color or shade so people don't feel they are streaky.

My opinion is simple based off results I've had. Maybe I'm extremely lucky at getting crits on vassal and extremely bad at rolling evades on vassal. My evade dice tend to roll blanks more then not in real life. So rolling focuses on vassal is a step up.