 Feature Articles
 CodeSOD
 Error'd
 Forums

Other Articles
 Random Article
 Other Series
 Alex's Soapbox
 Announcements
 Best of…
 Best of Email
 Best of the Sidebar
 Bring Your Own Code
 Coded Smorgasbord
 Mandatory Fun Day
 Off Topic
 Representative Line
 News Roundup
 Editor's Soapbox
 Software on the Rocks
 Souvenir Potpourri
 Sponsor Post
 Tales from the Interview
 The Daily WTF: Live
 Virtudyne
Admin
At least half of my runs look like this:
but I did manage a successful run at last:
The code is some pretty basic ruby to run the simulation.
Admin
And of course, without an account I can't edit my post. I went with an initial bet of 25% of current (or minimum) and a repeated 50% bumpup on loss (rather than only bumping once).
Admin
I think you need to watch that again. For sequences of a given length where all outcomes are equally likely (eg for fair coins or dice, but not red/black/zero on roulette wheels), all sequences ARE equally likely. So HTHTHT is as likely as HHHHHH.
That video shows that not all equal length subsequences within a larger sequence are equally likely, which is a different thing altogether, and not relevant to this question.
Admin
The fact that a table was showing 4 reds in a row does not affect the probability of the next roll being black or red, in the slightest bit!
Each roll of the wheel is independent in probability from the last roll. Black or Red odds will always be a little less than 50% (because of the 2 greens, depending on the wheel)
I always find it amusing at casinos when people are running up and down an aisle of roulette tables looking for streaks of black/red so they can bet the opposite.
Admin
The Real WTF is that no one actually posted any real code until the bottom of the first comment page.
Admin
The assignment wasn't to code a solution, it was to code a simulator. As a video game programmer in training, I find it to be rather relevant.
Admin
Used 50/50 odds and any profit was usually correlated to how many tables there were rather than rounds. However as soon as i changed the probability to include the two green spaces i started losing more then winning.
Admin
What are the odds of flipping a coin 4 times and getting heads every time? What are the odds of flipping a coin 5 times and getting heads every time?
Admin
It depends on your definition of win
If by win you mean increase your bankroll, then you cannot win. The simple reason being that the only way to gaurantee a 'win' is to have an infinite bankroll. If I have an infinite bankroll and I add $1 to it, I still have an infinite bankroll.
Also, if my bankroll was countably infinite adding a constant leaves it countably infinite. If it was uncountably infinite adding a constant leaves it as such. So I cannot even increase the "size" of my infinity.
However if by win you mean dividing the game into rounds and see that you come out of the round with more than you went in, then you can indeed win. A round would be defined as starting when you place your first bet and ending when you win for the first time. You come out of that with $bet more than you entered.
The question then becomes how can I make sure I have enough to complete a round and the answer bring us back to the infinity issue.
However, if we have a situation where your bankroll was $1 and the casino was willing to give you an infinite line of credit with 0 interest then you could come out on top using the system as your first win would allow you to pay off your debt and end with $2.
In laymans terms, If I have infinite time and money why am I spending it betting on a coin toss to win $1?
Admin
Unfortunately the chance of black or red does not matter on what came before, so there is always a 1 in 2 chance of it being either red or black.
An interesting article in New Scientist discussed this a couple of weeks ago, having 20 blacks in a row has the same probability as having red, black, red, black etc.
Admin
Supposedly, Albert Einstein once commented that the only way to make money playing roulette is to steal it off the table when the croupier isn't looking.
Admin
I don't believe it. If I saw a roulette wheel hit black 99 times in a row, I'd assume that it was rigged and bet against everyone else placing a bet on that spin.
Admin
Anyone care to explain the rules for 0 and 00?
Admin
Here's my enterprisey, bugridden PHP code.
http://pastie.org/588581
It seems to lose more often than win, so I won't be trying it at the casino any time soon... (either that or php's rand() isn't the greatest)
Admin
Actually "The Perch" is one way to "conserve" your money. Unless there are a large number of visible tables, one will spend a significant amount of time on the perch  and therefore NOT losing money.....
Admin
I'm learning Python so I decided try it with this problem. Instead of trying to meet the specifications, I went for the bonus points (what's the probability of gaining $400).
This is by no means an efficient piece of code. Like I said I'm still learning:
Output:
Admin
Yeah, this one is a lot easier than the last one, especially since all of the rules can be boiled down to:
Pick a random number in [0,1]
Win $10 if it's <2*(9/19)^6 Else, Win $20 if it's <2*(9/19)^6+2*(9/19)^6*(10/19) Else, Lose $25 if it's <2*(9/19)^6+2*(9/19)^6*(10/19)+2*(9/19)^5*(10/19)^2 Otherwise, no change*
The number of tables is only relevant to determining how long it takes to go out (and the assumption that you can only bet on one table at a time makes this dependence tricky) and the actual record of red/blacks is entirely moot.
On the other hand, simulating the physics of an actual roulette wheel could make it much harder and much more interesting.
*I sometimes screw up probability calculations, so I may be missing something here.
Admin
IIRC, betting Zero usually pays out at 35:1.
The number of zeros available depends on the house though  casinos can have between one and three zeros which obviously affects the profit margin.
Admin
[quote user="Not always wrong"][quote user="Roflo"]AnyoneIIRC, betting Zero usually pays out at 35:1.[/quote]Sorry, that should be 'betting a specific Zero' If you bet on 0 and 00 comes up, you still lose.
Admin
Where we go, crappy C++:
Admin
Of course, this is the theoretical part where there is 18/38 chance to win. Don't forget the zeros! In reality, that is only what the chance is supposed to be. The laws of physics says that the chance is likely not exactly that depending on a lot of random factors related to the physical motion. Some guy avenged them for a casino and found an extra lucky wheel.
Admin
I don't code much any more, but here's the pseudocode for a highlyoptimized algorithm:
#define MAX_TURNS = 40 (I'm not going to spend more than 40 times watching the little ball go around
generate all possible balllandings for the tables (38**MAX_TURNS) * T. Merge each 40character table sequence (evenly) into a single string (length 40*T).
Replace even numbers with "B" and odd numbers with "R"
Search for strings of R(T1 other letters)R(T1 other letters)R(T1 other letters)R(T1 other letters)R (this is a win). Replace the first R in that sequence with a +.
Search for strings of R(T1 other letters)R(T1 other letters)R(T1 other letters)R(T1 other letters)B (this is a loss). Replace the first R in that sequence with a .
Search for strings of B(T1 other letters)B(T1 other letters)B(T1 other letters)B(T1 other letters)B Replace the first B with a +.
Search for strings of B(T1 other letters)B(T1 other letters)B(T1 other letters)B(T1 other letters)R. Replace the first B with a 
Walk through the 38**MAX_TURNS and count +'s, subtracting 's until you get to either the end of the string (in which case you left with a profit) or a total of 0 (you lost your money) Associate that value with the strings.
Sort the list of 38**MAX_TURNS by the associated won value.
The first one in the resulting list is the most you can possibly win. The number of nonzero items / 38**MAX_TURNS is the probability of winning.
This doesn't do the bet1.5 if you lose rule, but a simple addition of another pair of regexps would fix that.
Joe
Admin
Some casinos have displays on each roulette table that show the most recent numbers. Many also distribute pads and pencils so players can do their own recording.
Admin
Isn't this the gambler's fallacy? (It might work, but it's fallacious.)
Admin
Admin
The probability of red or black is not 0.5, Vegas tables have one and sometimes two green spaces.
Admin
I was in a casino in Vegas with some friends some weeks ago, playing roulette (not me, I said I made too much maths for playing roulette). My friend played red when the last 4 (or five) moves were blacks. The roulette's guy told him, the most seriously possible : "don't play against the color".
And of course, he lost all of his money :)
Admin
quoteunquote empty string
Admin
I'm no Python expert wouldn't
never turn up a zero?Admin
Clearly I'm no English expert today, either. I meant "I'm no Python expert but wouldn't..."
Admin
Admin
Admin
$ java Play Wins: 3334  33.34 Loss: 6666  66.659996 Wins: 3332  33.32 Loss: 6668  66.68
Now assuming I've not messing something up (quite likely) it makes no difference.
Admin
Given the number of people offering unrequired lectures on statistics and the Gambler's Fallacy, perhaps the next BYOC problem should be to code up the BoyGirl Paradox?
Or if that is too easy then possibly go for Monty Hall? :)
Admin
In an infinite sequence you have certain subsequences which 'clump' together due to repetition but these clumps are further apart.
What this means is that when taking any finite sequence of flips there's a chance that it will fall in the middle of a clump and a chance that it will fall between clumps. You end up with subsequences that will, in laymans terms, happen a lot or happen a little but not usually an average amount. The cases for 'a lot' of an occurrence and 'a little' come up more often than 'average'.
For a sequence like HTH you have the chance to get a run like HTHTHTH and get several in a row.
For HTT you have a 50% chance to 'start' the sequence, then 50% to proceed and 50% to restart, then 50% to win and 50% to restart. Compared to HTH where you have a 50% chance to start, then 50% to proceed and 50% to restart, then 50% to win or 50% to lose.
Admin
Not that is changes the results:
Admin
Nothing to do with code, but I read Harry Anderson's "Games You Can't Lose: A Guide for Suckers" when I was younger. Been a while, but I do recall his advice for roulette was to bet with a run of a specific color/number/area of the wheel. His theory was that there may be a "sweet spot" on the wheel that favors that particular location.
He does warn, though, that nobody beats the house. :)
Admin
Err.. That seems obvious. The odds that she has a boy and girl at the end of the statement is 2/3rds.
Four possibles: BB BG GB GG
The question "Is at least one a girl?" eliminates the first option, leaving three. 2/3 of those are one girl, one boy. Simple.
Note that you also have to assume that the children's genders are independent of each other, which is actually not the case in reallife siblings with the same parents.
Admin
What this is essentially saying is that it is more likely the wheel isn't 100% fair than that a certain sequence appears.
To equate to flipping a coin. Lets assume I don't know if the coin is fair or not (similar to a roulette wheel in a casino, I don't know for sure that it's not imbalanced). If I see someone taking $1 bets on a coin, H means you win $3 T means you lose. If I also see them flip 10 T in a row I begin to become skeptical of this coin and think that it's weighted to come up with T more often as the chance of a fair coin hitting 10 Ts (roughly .1%) is less than the chance of someone abusing a weighted coin to take money from people.
Admin
The confusing part is that if you look at a sequence of 5 BEFORE you start, there's fairly low odds of them all coming out the same color.
However, if you have a PREVIOUS sequence of a color, the odds are 50/50 (assuming no rigging and only 2 possible outcomes) that the next roll will be the same color.
So the odds of 5 black in a row are different from the odds of the next roll being black (given itdoesn'tmatter already happened before).
Of course, it's probably hard to remember that in the gambling place after drinks. :P
And apparently the script thinks I'm a spammer for some reason? Or is that a REAL error this time? No real way to know  maybe if I remove the word casino?
EDIT: Well  that did it. Except I realized that I had "the word" again below so who knows how this thing works. TRWTF is TDWTF
Admin
Your netbook doesn't like to leave home without legal representation?
Admin
Ugly Python version:
The index of code entries is as allways at http://tinyurl.com/mcxts8 (tinyurl to pass thru spam filter)
Admin
No shit, Sherlock. This is a tongueincheek article prompting us to write some wtf code.
Check your aspie's at the door next time before you go off on a rant.
Admin
Quickly in Ruby (assumes no minimum bet):
Admin
Actually, you can regularly win at gambling  if you own the casino.
Admin
TRWTF is why anyone would write a program when it can (and should) be solved analytically. This is a random walk process. A random walk has a zero mean and a variance that grows as O(sqrt t). Every random walk will eventually cross the +400 mark, but the time to do that is a random function, and there is also a finite probability of crossing the 1,000,000 mark before that time.
http://en.wikipedia.org/wiki/Random_walk
Admin
It'll be tough to test The Perch without a properly balanced roulette wheel. Here is one coded in Python:
Admin
'The odds' refers to the payout in this instance. A $10 bet pays out $10 winnings plus your $10 stake retued = $20.
Admin
0 and 00 are there to tip the odds in favor of the house. You can bet on them but all computations are based on there being only 36 outcomes.
0 and 00 pay of 36:1 green pays off 18:1
Admin
If only it were so simple.
Here's an interesting article: http://mathworld.wolfram.com/CoinTossing.html