Ejemplo n.º 1
0
        private void btnOdds_Click(object sender, System.EventArgs e)
        {
            BJResults Results = new BJResults();

            float startingCash = 99999f;
            float bet = 10f;
            int index = 0;
            bool trend = true;
            bool stayBet = false;
            
            
            // prepare the shoe
            int numDecks = 5;
            int totalCards = numDecks * 52;
            Card[] deck = new Card[totalCards];
            for (int i = 0; i < totalCards; i++)
                deck[i] = new Card();

            float totalCash = startingCash;
            for (int i = 0; i < 2000; i++)//many many times
            {
                index = 0;
                float cash = startingCash;
                totalCash -= cash;

                Shuffle(ref deck, numDecks);

                while (index < (numDecks * 52) - 60) //leave a few cards
                {
                    PlayHand(ref cash, ref bet, 10, trend, ref stayBet, ref Results, deck, ref index, 1, 2, false);
                }

                totalCash += cash;
            }

            lblOddsGames.Text = "2000 decks played";

            DisplayOdds(Results, totalCash - startingCash);
        }
Ejemplo n.º 2
0
        private void PlayBigDeck(ref Card[] Cards, ref float Cash, float startingCash,
            ref BJResults Results, StreamWriter csvWriter)
        {
            float bet = System.Convert.ToInt32(txtStartingBet.Text, 10);
            float originalBet = bet;
            float originalCash = Cash;
            int maxPlayers = System.Convert.ToInt32(txtPlayers.Text, 10);
            int mySeat = System.Convert.ToInt32(txtSeatingPos.Text, 10);
            bool quitWhenAhead = chkQuitWhenAhead.Checked;
            double percentGains = System.Convert.ToDouble(txtPercentGains.Text);
            percentGains = (percentGains + 100) / 100;
            int index = 0;//card index
            bool trend = true;//MattLee Special (21) trend
            bool stayBet = false;//for pushes
            bool doubled = false;//keep track if we doubled-down

            int iMinShoeSize = 52 * 2;
            while (index < Cards.Length - iMinShoeSize && Cash > 0)//leave 2 decks unplayed
            {
                if (quitWhenAhead)
                {
                    if (Cash >= startingCash * percentGains)
                        break;
                }
                //csvWriter.WriteLine("{0}, {1}", Cash, bet);
                csvWriter.WriteLine("{0}, {1}, {2}", Cash, bet, lifeTimeCash);

                PlayHand(ref Cash, ref bet, originalBet, trend, ref stayBet, ref Results, Cards, ref index, mySeat, maxPlayers, doubled);
            }
        }
Ejemplo n.º 3
0
        private void DisplayResults(float Cash, int GamesPlayed, BJResults Results)
        {
            string result;
            result = String.Format("Cash Results: {0}  ", Cash.ToString("00000.00"));
            result += String.Format("Max Cash: {0}  ", Results.maxCash.ToString("00000.00"));
            result += String.Format("Min Cash: {0}  ", Results.minCash.ToString("00000.00"));
            result += String.Format("Hands Played: {0}  ", Results.HandsPlayed.ToString());
            result += String.Format("Win Pct: {0}  ", Results.WinPct.ToString("P"));
            result += String.Format("\nLifeTime Cash: {0}  ", lifeTimeCash);
            result += String.Format("LifeTime Spins: {0}  ", lifeTimeNumPlays);

            lblResults.Text = result;

            if (Cash > 2500 && Cash < 10000)
            {
                lblResults.ForeColor = Color.Red;
                Update();
                System.Threading.Thread.Sleep(250);
            }
            else if (Cash > 9999)
            {
                lblResults.ForeColor = Color.Orange;
                Update();
                System.Threading.Thread.Sleep(250);
            }
            else
            {
                lblResults.ForeColor = Color.Black;
                Update();
            }
        }
Ejemplo n.º 4
0
        private void PlayHand(ref float Cash, ref float bet, float originalBet, bool trend,
                    ref bool stayBet, ref BJResults Results, Card[] Cards, ref int index,
                    int mySeat, int maxPlayers, bool doubled)
        {
            CardHand dealerHand = new CardHand(15);
            CardHand myHand = new CardHand(15);

            Betting(Cash, ref bet, originalBet, trend,
                ref stayBet, Results.movement, Cards, index);

            InitialDeal(ref Cards, ref index, ref myHand, ref dealerHand,
                mySeat, maxPlayers);

            if (ThereIsABlackJack(myHand, dealerHand, ref Cash, bet,
                ref Results, ref trend))
            {
                return;
            }

            //double-down?
            if (chkDoubleDown.Checked)
            {
                if ((dealerHand.Showing == 4 || dealerHand.Showing == 5 ||
                    dealerHand.Showing == 6) && (myHand.Total == 10 ||
                    myHand.Total == 11))
                {
                    if (Cash > bet * 2)
                    {
                        bet = bet * 2;
                        doubled = true;
                    }
                }
            }

            HitStayBust(ref Cards, ref index, ref myHand, ref dealerHand,
                maxPlayers, mySeat, doubled);

            WrapUp(myHand, dealerHand, ref Cash, bet, ref Results);

            if (doubled)
            {
                bet /= 2;
                doubled = false;
            }
        }
Ejemplo n.º 5
0
        private void btnPlay_Click(object sender, System.EventArgs e)
        {
            string path = Path.Combine(System.Environment.CurrentDirectory, "data.csv");
            System.IO.StreamWriter csvWriter = System.IO.File.CreateText(path);

            float cash = System.Convert.ToInt32(txtCash.Text, 10);
            BJResults results = new BJResults();
            results.minCash = results.maxCash = cash;
            int totalGames = 0;
            int iTotalCount = 1;
            float totalCash = 0;
            Int32.TryParse(txtPlayCount.Text, out iTotalCount);
            for (int playCount = 0; playCount < iTotalCount; playCount++)
            {
                // prepare strategy
                int games = 0;
                cash = System.Convert.ToInt32(txtCash.Text, 10);
                float startingCash = cash;
                int maxGames = System.Convert.ToInt32(txtRoundsPlayed.Text, 10);
                int decks = System.Convert.ToInt32(txtDecks.Text, 10);
                bool quitWhenAhead = chkQuitWhenAhead.Checked;
                double percentGains = System.Convert.ToDouble(txtPercentGains.Text);
                percentGains = (percentGains + 100) / 100;

                // prepare the shoe
                int totalCards = decks * 52;
                Card[] Cards = new Card[totalCards];
                for (int i = 0; i < totalCards; i++)
                    Cards[i] = new Card();

                csvWriter.WriteLine("----New Play----");
                csvWriter.WriteLine("Cash, Bet");

                lifeTimeCash -= cash;
                totalCash -= cash;

                // playCount is your number of days played based on your strategy / exit
                for (games = 0; games < maxGames; games++)
                {
                    Shuffle(ref Cards, decks);//create the cards
                    PlayBigDeck(ref Cards, ref cash, startingCash, ref results, csvWriter);

                    if (cash <= 0)
                        break;
                    if (quitWhenAhead)
                    {
                        if (cash >= startingCash * percentGains)
                            break;
                    }
                }
                csvWriter.WriteLine("{0}, {1}, {2}", cash, 0, lifeTimeCash);
                csvWriter.Flush();

                lifeTimeCash += cash;
                totalCash += cash;
                lifeTimeNumPlays++;

                DisplayResults(cash, games, results);
            }
            DisplayResults(totalCash, totalGames, results);
            csvWriter.Close();
        }
Ejemplo n.º 6
0
        private void DisplayOdds(BJResults Results, float cash)
        {
            string result;
            result = String.Format("Cash out: {0}  ", cash);
            result += String.Format("Win Pct: {0}  ", Results.WinPct);
            result += String.Format("Pushes: {0}  ", Results.pushes);
            result += String.Format("\nmyBJ: {0}   dealerBJ: {1}",
                Results.myTwentyones, Results.dealerTwentyones);

            lblResults.Text = result;
        }
Ejemplo n.º 7
0
        private void WrapUp(CardHand myHand, CardHand dealerHand,
            ref float Cash, float Bet, ref BJResults Results)
        {
            //If player or dealer hit 21 on deal, we already took care of things.
            //Did we win?
            if ((myHand.Total > dealerHand.Total && myHand.Total < 22) ||
                (dealerHand.Total > 21 && myHand.Total < 22))
            {
                Cash += Bet;
                Results.wins++;
                if (Results.movement < 0)
                    Results.movement = 0;
                else
                    Results.movement++;
            }
            else if ((myHand.Total > 21) ||
                (myHand.Total < dealerHand.Total))
            {
                Cash -= Bet;
                Results.losses++;
                if (Results.movement > 0)
                    Results.movement = 0;
                else
                    Results.movement--;
            }
            else
            {
                Results.pushes++;
                //stayBet = true;
            }

            if (Cash > Results.maxCash)
                Results.maxCash = Cash;
            if (Cash < Results.minCash)
                Results.minCash = Cash;

        }
Ejemplo n.º 8
0
        private bool ThereIsABlackJack(CardHand myHand, CardHand dealerHand,
            ref float Cash, float Bet, ref BJResults Results, ref bool trend)
        {
            //Did dealer get 21?
            if (dealerHand.Total == 21)
            {
                Cash -= Bet;
                Results.dealerTwentyones++;
                trend = false;
                if (Cash < Results.minCash)
                    Results.minCash = Cash;
                if (Results.movement > 0)
                    Results.movement = 0;
                else
                    Results.movement--;
                return true;
            }
            //Did we get 21?
            if (myHand.Total == 21)
            {
                Cash += Bet * 1.5f;
                Results.myTwentyones++;
                trend = true;
                if (Cash > Results.maxCash)
                    Results.maxCash = Cash;
                if (Results.movement < 0)
                    Results.movement = 0;
                else
                    Results.movement++;
                return true;
            }

            return false;
        }