/// <summary> /// Initializes a class from properties. /// For each preflop bucket it expects a a property in the following format: /// <para>name: "Pockets7", value: "AA KK QQ JJ TT 99 AKs"</para> /// <para>If there is no such properties at all, it is assumed that this CA does /// not use preflop pocket bucketizing. In this case the property PocketKindToAbstrCard returns null.</para> /// <para>If any such a property exists, than all other in range [1..bucketsCount-1] must be specified, /// otherwise an ArgumentException it thrown.</para> /// <para>All pockets unspecified in such properties go to bucket 0 (even if its property specifed explicitely).</para> /// </summary> public PreflopPocketCA(Props parameters, int bucketsCount) { bool isPreflopPocketBucketizingUsed = false; for (int b = bucketsCount - 1; b >= 0; --b) { string propName = "Pockets" + b.ToString(); string value = parameters.Get(propName); if (!string.IsNullOrEmpty(value)) { isPreflopPocketBucketizingUsed = true; break; } } if (!isPreflopPocketBucketizingUsed) { return; } PocketKindToAbstrCard = new int[(int)HePocketKind.__Count]; for (int b = bucketsCount - 1; b >= 0; --b) { string propName = "Pockets" + b.ToString(); string value = parameters.Get(propName); if (string.IsNullOrEmpty(value)) { if (b == 0) { // This can be left out. continue; } throw new ArgumentException(string.Format("Pockets{0} is not specified", b)); } string[] bucketKinds = value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); foreach (string kindString in bucketKinds) { HePocketKind kind = HePocket.StringToKind(kindString); PocketKindToAbstrCard[(int)kind] = b; } } }
public static void PrintPreflopRanges(IChanceAbstraction ca) { List <HePocketKind>[] abstrRanges = new List <HePocketKind> [0]; int[] abstrRangesSizes = new int[0]; for (int p = 0; p < (int)HePocketKind.__Count; ++p) { HePocketKind kind = (HePocketKind)p; CardSet pocketCS = HePocket.KindToCardSet(kind); int [] pocketArr = StdDeck.Descriptor.GetIndexesAscending(pocketCS).ToArray(); int abstrCard = ca.GetAbstractCard(pocketArr, pocketArr.Length); if (abstrCard >= abstrRanges.Length) { Array.Resize(ref abstrRanges, abstrCard + 1); Array.Resize(ref abstrRangesSizes, abstrCard + 1); } if (abstrRanges[abstrCard] == null) { abstrRanges[abstrCard] = new List <HePocketKind>(); } abstrRanges[abstrCard].Add(kind); abstrRangesSizes[abstrCard] += HePocket.KindToRange(kind).Length; } Console.WriteLine("Preflop ranges of CA: {0}", ca.Name); int total = 0; for (int i = abstrRanges.Length - 1; i >= 0; --i) { Console.Write("{0,2} ({1,4}):", i, abstrRangesSizes[i]); foreach (HePocketKind k in abstrRanges[i]) { Console.Write(" {0}", HePocket.KindToString(k)); } Console.WriteLine(); total += abstrRangesSizes[i]; } Console.WriteLine("Total: {0}", total); }
public void Update(GameRecord gameRecord) { for (int pos = 0; pos < gameRecord.Players.Count; ++pos) { GameRecord.Player player = gameRecord.Players[pos]; if (player.Name == _hero) { Allocate(pos); foreach (PokerAction action in gameRecord.Actions) { if (action.Kind == Ak.d && action.Position == pos) { CardSet pocket = StdDeck.Descriptor.GetCardSet(action.Cards); HePocketKind pocketKind = HePocket.CardSetToKind(pocket); _positions[pos][(int)pocketKind].count++; _positions[pos][(int)pocketKind].result += player.Result; } } break; } } }
public static Result Calculate(HePocketKind p1, HePocketKind p2) { CardSet[] csRange1 = HePocket.KindToRange(p1); CardSet[] csRange2 = HePocket.KindToRange(p2); return(CalculateNoVerify(csRange1, csRange2)); }