static PlayResults PlayAutomated(VideoPokerMachine vp, decimal creditValue, int handsPlayed, int dollarPerTierCredit, int startingBankroll, int targetPoints, string playerType = "Job") { vp.Credits = (int)(startingBankroll / creditValue); vp.HandsBet = handsPlayed; var player = new VpPlayer(System.Reflection.Assembly.GetAssembly(typeof(VpPlayer)).GetTypes() .Where(t => typeof(IHandTier).IsAssignableFrom(t) && t != typeof(IHandTier)) .Where(t => t.Namespace.Contains(playerType)) .Select(ht => Activator.CreateInstance(ht)) .OfType <IHandTier>() .ToArray()); var coinIn = 0; var hands = 0; //var i = 0; while (true) { if ((int)((coinIn * creditValue) / dollarPerTierCredit) >= targetPoints) { //Console.WriteLine("************** Made Plat! *******************"); break; } if (vp.Credits < vp.BetPerHand * vp.HandsBet) { vp.Credits = 0; //Console.WriteLine("!!!!!!!!!!!!!BUSTED!!!!!!!!!!!!!!!!"); break; } vp.MaxBet(); coinIn += vp.BetPerHand * vp.HandsBet; hands++; foreach (var hold in player.GetHolds(vp.Hand)) { vp.Hold(hold); } vp.Deal(); /* * i++; * if(i%100==0) * { * Console.WriteLine("Credits: {0} Tier Credits:{1}", vp.Credits, (int)((coinIn * creditValue) / dollarPerTierCredit)); * }*/ } return(new PlayResults { CreditsLeft = vp.Credits, CoinIn = coinIn, TierCredits = (int)((coinIn * creditValue) / dollarPerTierCredit), HandsPlayed = hands }); }
static PlayResults PlayManual(VideoPokerMachine vp, decimal creditValue, int handsPlayed, int dollarPerTierCredit, int startingBankroll) { vp.Credits = (int)(startingBankroll / creditValue); vp.HandsBet = handsPlayed; var coinIn = 0; while (true) { Console.WriteLine("Credits Available: {0}", vp.Credits); Console.WriteLine("Tier Credits Earned: {0}", (int)((coinIn * creditValue) / dollarPerTierCredit)); if ((int)((coinIn * creditValue) / dollarPerTierCredit) >= 5000) { Console.WriteLine("************** Made Diamond! *******************"); Console.ReadKey(); break; } if (vp.Credits < vp.BetPerHand * vp.HandsBet) { Console.WriteLine("!!!!!!!!!!!!!BUSTED!!!!!!!!!!!!!!!!"); Console.ReadKey(); break; } Console.WriteLine("Press space to max bet"); var key = Console.ReadKey().KeyChar; if (key != ' ' && key != '0') { break; } vp.MaxBet(); coinIn += vp.BetPerHand * vp.HandsBet; key = 'x'; while (key != ' ' && key != '0') { Console.WriteLine(); for (var i = 0; i < vp.Hand.Length; i++) { if (vp.Hand[i].Suit % 2 == 0) { Console.ForegroundColor = ConsoleColor.White; } else { Console.ForegroundColor = ConsoleColor.Red; } Console.WriteLine("{0} {1}: {2}", vp.Holds[i] ? "X" : " ", i + 1, vp.Hand[i]); } Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(); var patHand = vp.CheckCurrentHand(); if (patHand.Payout > 0) { Console.WriteLine("\r\n-------Dealt a {0}!-------\r\n", patHand.PayLineHit); } Console.WriteLine("Space or 0 for deal, 1-5 to hold."); key = Console.ReadKey().KeyChar; switch (key) { case '1': vp.Hold(0); break; case '2': vp.Hold(1); break; case '3': vp.Hold(2); break; case '4': vp.Hold(3); break; case '5': vp.Hold(4); break; } } using (var writer = new StreamWriter("c:\\vptests.cs", true)) { var holds = new List <int>(); for (var i = 0; i < vp.Holds.Length; i++) { if (vp.Holds[i]) { holds.Add(i); } } writer.WriteLine("\r\n[Test]"); writer.WriteLine("public void GeneratedTest_{0}()", Guid.NewGuid().ToString().Replace("-", "")); writer.WriteLine("{"); writer.WriteLine("var holds = _player.GetHolds(Card.Hand({0}));", vp.Hand.Select(c => String.Format("\"{0}\"", c)).Aggregate((a, b) => a + ", " + b)); writer.WriteLine(); writer.WriteLine("holds.Should().HaveCount({0});", holds.Count); foreach (var hold in holds) { writer.WriteLine("holds.Should().Contain({0});", hold); } writer.WriteLine("}\r\n"); } vp.Deal(); Console.WriteLine("Results:"); foreach (var result in vp.Results) { Console.WriteLine("Hand: {0} Payout {1} for {2}", result.Hand.Select(c => c.ToString()).Aggregate((a, b) => a + " " + b), result.Payout, result.PayLineHit); } Console.WriteLine(); if (vp.HandsBet > 10) { Console.WriteLine("Payout Summary:"); foreach (var payLine in vp.Results.GroupBy(pl => new { pl.PayLineHit, pl.Payout }).OrderBy(pl => pl.Key.Payout)) { Console.WriteLine("{0}: {1} hits, {2} each for {3} total", payLine.Key.PayLineHit, payLine.Count(), payLine.Key.Payout, payLine.Select(pl => pl.Payout).Sum()); } Console.WriteLine(); } Console.WriteLine("Total payout {0}", vp.Results.Select(r => r.Payout).Sum()); } return(new PlayResults { CreditsLeft = vp.Credits, CoinIn = coinIn, TierCredits = (int)((coinIn * creditValue) / dollarPerTierCredit) }); }