When I simulated just 100 trials, there were a number of identical net win/loss results that occured twice. Is my logic, or random number generation the problem?
One way to approach this is to strip out everything extraneous. This bisects the problem. If the symptoms go away, you have a pretty good idea which side of the line the problem lies on.
Something like the following may help you gain some insight:
use Math::Random;
for ( 1 .. 100 ) {
my $d1 = random_uniform_integer(1,1,6);
my $d2 = random_uniform_integer(1,1,6);
print $d1 + $2, "\n";
}
Does this produce results consistent with what you're seeing?
Is also helps, when asking people to review your code, to indent. Unindented code is hard to read, and many people will take one look at it and walk away.
Oh, and use strict; to avoid accidental globals like $roll.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.