private static HandProbabilities CreateHandProbability(ulong pockets, ulong board, int opponents) { HandProbabilities prob = new HandProbabilities(pockets, board, opponents); return prob; }
private static HandProbabilities CreateHandProbability(ulong pockets, ulong board, int opponents) { HandProbabilities prob = new HandProbabilities(pockets, board, opponents); return(prob); }
public static void CreateTurnLookUpTable(int numOpponents) { int situations = 0; int skipped = 0; CreateHandProbabilityDelegate d = new CreateHandProbabilityDelegate(CreateHandProbability); Dictionary <ulong, HashSet <ulong> > lookupTable = new Dictionary <ulong, HashSet <ulong> >(); foreach (ulong pockets in PocketHands.Hands169()) { Hand.PocketHand169Enum handType = Hand.PocketHand169Type(pockets); ulong[] flops = EnumerateFlop(pockets); situations += flops.Length; Console.WriteLine("Hand: {0}", Hand.MaskToString(pockets)); List <ulong> pocketList = new List <ulong>(); List <ulong> boardList = new List <ulong>(); foreach (ulong flop in flops) { for (int t = 51; t >= 0; t--) { ulong turn = Hand.Mask(t); if (Hand.BitCount(pockets | flop | turn) != 6) { continue; } ulong isoPockets, isoTurn; Transform(pockets, flop | turn, out isoPockets, out isoTurn, false); if (!lookupTable.ContainsKey(isoPockets)) { lookupTable.Add(isoPockets, new HashSet <ulong>()); } if (lookupTable[isoPockets].Contains(isoTurn)) { skipped++; continue; } lookupTable[isoPockets].Add(isoTurn); pocketList.Add(isoPockets); boardList.Add(isoTurn); } } IAsyncResult[] results = new IAsyncResult[pocketList.Count]; for (int i = 0, r = 0; i < pocketList.Count; i++) { results[r++] = d.BeginInvoke(pocketList[i], boardList[i], numOpponents, null, null); } Dictionary <ulong, List <HandProbabilities> > probabilities = new Dictionary <ulong, List <HandProbabilities> >(); for (int i = 0; i < results.Length; i++) { HandProbabilities prob = d.EndInvoke(results[i]); if (!probabilities.ContainsKey(prob.Pockets)) { probabilities.Add(prob.Pockets, new List <HandProbabilities>()); } probabilities[prob.Pockets].Add(prob); } foreach (var pair in probabilities) { SaveProbabilities(pair.Value, pair.Key, numOpponents, Round.Turn); } } }
public static void CreateFlopLookUpTable() { int situations = 0; int skipped = 0; CreateHandProbabilityDelegate d = new CreateHandProbabilityDelegate(CreateHandProbability); Dictionary <ulong, HashSet <ulong> > lookupTable = new Dictionary <ulong, HashSet <ulong> >(); foreach (ulong pockets in PocketHands.Hands169()) { Hand.PocketHand169Enum handType = Hand.PocketHand169Type(pockets); ulong[] flops = EnumerateFlop(pockets); situations += flops.Length; Console.WriteLine("Hand: {0} Flops: {1}", Hand.MaskToString(pockets), flops.Length); List <ulong> pocketList = new List <ulong>(); List <ulong> boardList = new List <ulong>(); foreach (ulong flop in flops) { ulong isoPockets, isoFlop; Transform(pockets, flop, out isoPockets, out isoFlop, false); if (!lookupTable.ContainsKey(isoPockets)) { lookupTable.Add(isoPockets, new HashSet <ulong>()); } if (lookupTable[isoPockets].Contains(isoFlop)) { skipped++; continue; } lookupTable[isoPockets].Add(isoFlop); pocketList.Add(isoPockets); boardList.Add(isoFlop); } IAsyncResult[] results = new IAsyncResult[pocketList.Count * 5]; for (int i = 0, r = 0; i < pocketList.Count; i++) { results[r++] = d.BeginInvoke(pocketList[i], boardList[i], 1, null, null); results[r++] = d.BeginInvoke(pocketList[i], boardList[i], 2, null, null); results[r++] = d.BeginInvoke(pocketList[i], boardList[i], 3, null, null); results[r++] = d.BeginInvoke(pocketList[i], boardList[i], 4, null, null); results[r++] = d.BeginInvoke(pocketList[i], boardList[i], 5, null, null); } Dictionary <ulong, List <HandProbabilities> >[] probabilities = new Dictionary <ulong, List <HandProbabilities> > [5]; for (int i = 0; i < 5; i++) { probabilities[i] = new Dictionary <ulong, List <HandProbabilities> >(); } for (int i = 0; i < results.Length; i++) { HandProbabilities prob = d.EndInvoke(results[i]); if (!probabilities[prob.OpponentCount - 1].ContainsKey(prob.Pockets)) { probabilities[prob.OpponentCount - 1].Add(prob.Pockets, new List <HandProbabilities>()); } probabilities[prob.OpponentCount - 1][prob.Pockets].Add(prob); } for (int opponents = 1; opponents <= 5; opponents++) { foreach (var pair in probabilities[opponents - 1]) { SaveProbabilities(pair.Value, pair.Key, opponents, Round.Flop); } } } Console.WriteLine("Situations: {0} Skipped: {1} Estimated time: {2} hours", situations, skipped, Math.Round(situations * 0.04 / 3600.0, 2)); }