Exemplo n.º 1
0
        private static BlackjackSettings LoadSettingsFromFile(string file)
        {
            BlackjackSettings settings = null;
            XmlSerializer     ser      = new XmlSerializer(typeof(BlackjackSettings));

            using (TextReader writer = new StreamReader(file))
                settings = (BlackjackSettings)ser.Deserialize(writer);
            return(settings);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //BlackjackSettings settings = SaveDefaultSettings();
            BlackjackSettings settings = LoadSettingsFromFile("settings.xml");
            BlackjackGame     game     = new BlackjackGame(settings);

            //ConsoleBlackjackPlayer player = new ConsoleBlackjackPlayer() { Game = game };
            var handsToPlay = 100000000L;
            var player      = new BasicStrategyPlayer(handsToPlay);

            game.Play(new [] { player });
            Console.WriteLine("Profit: {0}%", Math.Round((player.Profit / settings.MinimumBet / (decimal)handsToPlay) * 100m, 2));
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            BlackjackSettings settings = LoadSettingsFromFile("settings.xml");
            BlackjackGame     game     = new BlackjackGame(settings);

            var handsToPlay = 100000000L;

            //BasicStrategyPlayer basic = new BasicStrategyPlayer(handsToPlay);
            //var table = ActionTable.FromStrategy(basic);

            //var player = basic;
            //var player = new ConsoleBlackjackPlayer() { Game = game };
            //var player = new WizardSimpleStrategy(handsToPlay);
            //var player = new ActionTablePlayer(table, handsToPlay) { Print = true };
            var player = new SimpleFiveCountPlayer(handsToPlay);

            game.Play(new [] { player });
            Console.WriteLine("Profit: {0:N2}%",
                              player.Profit / settings.MinimumBet / (decimal)handsToPlay * 100m);
        }
Exemplo n.º 4
0
        private static BlackjackSettings SaveDefaultSettings()
        {
            BlackjackSettings settings = new BlackjackSettings()
            {
                DecksPerShoe = 8,
                MinCardsDealtBeforeReshuffle = 230,

                MinimumBet = 5,
                MaximumBet = 200,

                DealerHardStandThreshold = 17,
                DealerSoftStandThreshold = 18,

                BlackjackPayoff = 2.5m,

                InsuranceOffered = true,
                InsuranceCost    = 1m,
                InsurancePayoff  = 2m,

                ResplitAcesAllowed = true,
                SplitTensAllowed   = true,

                HittingSplitAcesAllowed = true,

                DoubleDownOnlyTenOrEleven     = false,
                SoftDoubleDownAllowed         = true,
                DoubleDownNonAceSplitsAllowed = true,
                DoubleDownSplitAcesAllowed    = false,

                SurrenderAllowed = true,
                SurrenderPayoff  = 0.5m
            };
            XmlSerializer ser = new XmlSerializer(typeof(BlackjackSettings));

            using (TextWriter writer = new StreamWriter("settings.xml"))
                ser.Serialize(writer, settings);
            return(settings);
        }