C#

Moderators: None (Apply to moderate this forum)
Number of threads: 2720
Number of posts: 5746

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
solved Posted by jacobcyh on 24 May 2009 at 4:35 AM
Hi all.

I'm new to C# and i'm trying to create a program that simulates Martingale's system of coin toss betting.

Problems i'm facing now:

1)Generating fair coin tosses with the Random function
2)Comparing the current toss with the previous tosses to invoke Methods

I've read through several beginners guides and know the basics, but I cant find anything specific to these problems highlighted above.

Any help would be greatly appreciated.

Thanks!

-solved-
Report
Re: solved Posted by Psightoplazm on 26 May 2009 at 8:11 AM
So the betting theory assumes a ficticious better with an infinite amount of money. It is based on the theory that the flip of a coin will always eventually even itself out. The betting method is to start with a bet - let's say 1 dollar - and then double it every time you lose. This way you eventually make back all of your money lost, plus profit.

Am I remembering that right?


Try this...

Random rnd = new Random();
double bet = 1.0;
double winnings = 0.0;

do
{
    Console.WriteLine("Current Winnings: " + winnings);
    Console.WriteLine("Betting " + bet + " on heads:");
    Console.WriteLine("Press any key to proceed...");
    Console.ReadKey();
    var flip = rnd.Next(100);// 100 gives us a more even chance
    if (flip >= 50)
    {
        Console.WriteLine("Winner!");
        winnings += bet;
    }
    else
    {
        Console.WriteLine("Loser!");
        winnings -= bet;
        bet *= 2;
    }
} while(true);
    

></\/~Psightoplasm`~



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.