solved - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

solved

jacobcyhjacobcyh Posts: 1Member
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-

Comments

  • PsightoplazmPsightoplazm Posts: 332Member ✭✭
    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...

    [code]
    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);

    [/code]
    ><//~Psightoplasm`~
Sign In or Register to comment.