public static void Begin(HandTracker handTracker, int tableCount, int handsToPlayPerTable) { var startTime = DateTime.Now; var processesRemaining = tableCount; using ManualResetEvent resetEvent = new ManualResetEvent(false); for (int i = 0; i < tableCount; i++) { ThreadPool.QueueUserWorkItem(new WaitCallback(x => { var tracker = (HandTracker)x; var table = new Table(3, true, 40, 40, tracker); table.PlayHands(handsToPlayPerTable, false); // Safely decrement the counter if (Interlocked.Decrement(ref processesRemaining) == 0) { resetEvent.Set(); } }), handTracker); } resetEvent.WaitOne(); var endTime = DateTime.Now; var duration = (endTime - startTime).TotalSeconds; Console.WriteLine($"Finished in {duration} seconds"); }
public static void Main(string[] args) { //Console.WindowHeight = 50; //Console.WindowWidth = 200; var handTracker = new HandTracker(true); TablePlayer.Begin(handTracker, 30, 1_000_000); var input = ""; //Console.ReadKey(); Console.Clear(); //handTracker.PrintHoleCardWinRatesRankedByBest(input); //handTracker.PrintHoleCardsNumericRankedByBestForArray(); //handTracker.PrintHoleCardsRankedByBestForArray(); //if (handTracker.LogPokerHandResults) //{ // handTracker.PrintWinRatesForPokerHandsMade(input); //} while (input != "exit") { Console.Clear(); Console.WriteLine("Enter a hand"); input = Console.ReadLine(); if (input == "exit") { continue; } handTracker.PrintHoleCardWinRatesRankedByBest(input); Console.ReadKey(); } }