public void Test_Calculate_Range() { DeckDescriptor d = StdDeck.Descriptor; CardSet[] range1 = new CardSet[] { d.GetCardSet("Ac Ah"), d.GetCardSet("Kc Kd") }; CardSet[] range2 = new CardSet[] { d.GetCardSet("7h 6h"), d.GetCardSet("5c 4d") }; PocketEquity.Result r = PocketEquity.Calculate(range1, range2); Assert.AreEqual(0.79960, r.Equity, 0.000005); Assert.AreEqual(4, r.Count); }
public void Test_CardSetToKind() { Assert.AreEqual(169, (int)HePocketKind.__Count); DeckDescriptor deck = StdDeck.Descriptor; Assert.AreEqual(HePocketKind._AQo, HePocket.CardSetToKind(deck.GetCardSet("Ac Qd"))); Assert.AreEqual(HePocketKind._AQo, HePocket.CardSetToKind(deck.GetCardSet("As Qc"))); Assert.AreEqual(HePocketKind._22, HePocket.CardSetToKind(deck.GetCardSet("2s 2c"))); Assert.AreEqual(HePocketKind._32s, HePocket.CardSetToKind(deck.GetCardSet("2s 3s"))); Assert.AreEqual(HePocketKind._32s, HePocket.CardSetToKind(deck.GetCardSet("3c 2c"))); }
public void Test_KindToCardset() { Assert.AreEqual(169, (int)HePocketKind.__Count); DeckDescriptor deck = StdDeck.Descriptor; Assert.AreEqual(deck.GetCardSet("Ac Ad"), HePocket.KindToCardSet(HePocketKind._AA)); Assert.AreEqual(deck.GetCardSet("Ac Kd"), HePocket.KindToCardSet(HePocketKind._AKo)); Assert.AreEqual(deck.GetCardSet("Ac Kc"), HePocket.KindToCardSet(HePocketKind._AKs)); Assert.AreEqual(deck.GetCardSet("7c 2d"), HePocket.KindToCardSet(HePocketKind._72o)); Assert.AreEqual(deck.GetCardSet("7c 5c"), HePocket.KindToCardSet(HePocketKind._75s)); //for (int i = 0; i < 169; ++i) //{ // HePocketKind pk = (HePocketKind)i; // Console.WriteLine("{0,-4}: {1}", pk, HePocket.KindToCardSet(pk)); //} }
public DealRecord(GameRecord cfg, DeckDescriptor deckDescr, SequenceRng randomDealer) { _cfg = cfg; _deckDescr = deckDescr; _randomDealer = randomDealer; // Loop through actions and // - find the fixed cards // - count random cards // - count enumerated cards for (int a = 0; a < _cfg.Actions.Count; ++a) { PokerAction action = _cfg.Actions[a]; if (!action.IsDealerAction()) { continue; } string[] cards = action.Cards.Split(_separator, StringSplitOptions.RemoveEmptyEntries); foreach (string card in cards) { if (card == "?") { _randomCount++; } else if (card.Length > 0 && card.Substring(0, 1) == "#") { int idx = int.Parse(card.Substring(1)); while (_enumCounts.Count <= idx) { _enumCounts.Add(0); _enumCombosCounts.Add(0); _enumCombos.Add(new List <CardSet>()); } _enumCounts[idx]++; } else { _fixedCards.UnionWith(_deckDescr.GetCardSet(card)); } } } // Count enumerated combinations. int deadCards = _fixedCards.CountCards(); for (int i = 0; i < _enumCounts.Count; ++i) { _enumCombosCounts[i] = EnumAlgos.CountCombin(_deckDescr.Size - deadCards, _enumCounts[i]); deadCards += _enumCounts[i]; } }
public void Test_CountEquiv() { DeckDescriptor dd = StdDeck.Descriptor; Assert.AreEqual(1, NormRank.CountEquiv(CardSet.Empty, dd)); Assert.AreEqual(4 * 4 * 4 * 4, NormRank.CountEquiv(dd.GetCardSet("Ac Kd Qc Jh"), dd)); Assert.AreEqual(16, NormRank.CountEquiv(dd.GetCardSet("Ac Kd"), dd)); Assert.AreEqual(4, NormRank.CountEquiv(dd.GetCardSet("Kd"), dd)); Assert.AreEqual(6, NormRank.CountEquiv(dd.GetCardSet("Kc Kd"), dd)); Assert.AreEqual(4, NormRank.CountEquiv(dd.GetCardSet("Kc Kd Ks"), dd)); Assert.AreEqual(1, NormRank.CountEquiv(dd.GetCardSet("7c 7d 7s 7h"), dd)); }
public void Benchmark_GetCardSet() { DeckDescriptor dd = StdDeck.Descriptor; int repetitions = 10000000; DateTime start = DateTime.Now; UInt64 sum = 0; for (int r = 0; r < repetitions; ++r) { sum += dd.GetCardSet(dd.CardNames[r % dd.Size]).bits; } double time = (DateTime.Now - start).TotalSeconds; Console.WriteLine("Repetitions: {0:#,#}, time: {1:0.00} s, rep/s: {2:#,#}", repetitions, time, repetitions / time); }
public void Test_Cardsets() { DeckDescriptor dd = new DeckDescriptor("TestDeck", _cardNames1, _cardSets1); Assert.AreEqual(0x00, dd.GetCardSet("").bits); Assert.AreEqual(0x00, dd.GetCardSet(" ").bits); Assert.AreEqual(0x01, dd.GetCardSet("Q").bits); Assert.AreEqual(0x01, dd.GetCardSet("Q ").bits); Assert.AreEqual(0x01, dd.GetCardSet(" Q").bits); Assert.AreEqual(0x01, dd.GetCardSet(" Q ").bits); Assert.AreEqual(0x11, dd.GetCardSet("Q A").bits); Assert.AreEqual(0x11, dd.GetCardSet("A Q").bits); Assert.AreEqual(0x11, dd.GetCardSet(" Q A").bits); Assert.AreEqual(0x11, dd.GetCardSet("A Q").bits); Assert.AreEqual(0x11, dd.GetCardSet("A Q ").bits); Assert.AreEqual(0x00, dd.GetCardSet(new string[] {}).bits); Assert.AreEqual(0x01, dd.GetCardSet(new string[] { "Q" }).bits); Assert.AreEqual(0x11, dd.GetCardSet(new string[] { "Q", "A" }).bits); Assert.AreEqual(0x11, dd.GetCardSet(new string[] { "A", "Q" }).bits); Assert.AreEqual(0x00, dd.GetCardSet(new int[] { }).bits); Assert.AreEqual(0x13, dd.GetCardSet(new int[] { 0, 2, 1 }).bits); Assert.AreEqual(0x13, dd.GetCardSet(new int[] { 1, 2, 0 }).bits); Assert.AreEqual(0x00, dd.GetCardSet(new int[] { 0, 2, 1 }, 1, 0).bits); Assert.AreEqual(0x12, dd.GetCardSet(new int[] { 0, 2, 1 }, 1, 2).bits); Assert.AreEqual(0x12, dd.GetCardSet(new int[] { 0, 1, 2 }, 1, 2).bits); }
public void Test_Convert() { DeckDescriptor dd = StdDeck.Descriptor; Assert.AreEqual(CardSet.Empty, NormRank.Convert(CardSet.Empty)); Assert.AreEqual(dd.FullDeck, NormRank.Convert(dd.FullDeck)); CardSet cs = new CardSet { bits = 0xFFFFFFFFFFFFFFFF }; Assert.AreEqual(cs, NormRank.Convert(cs)); Assert.AreEqual(dd.GetCardSet("Ac"), NormRank.Convert(dd.GetCardSet("Ac"))); Assert.AreEqual(dd.GetCardSet("Ac"), NormRank.Convert(dd.GetCardSet("Ad"))); Assert.AreEqual(dd.GetCardSet("Ac"), NormRank.Convert(dd.GetCardSet("Ah"))); Assert.AreEqual(dd.GetCardSet("Ac"), NormRank.Convert(dd.GetCardSet("As"))); Assert.AreEqual(dd.GetCardSet("Ac Kc"), NormRank.Convert(dd.GetCardSet("Ac Kc"))); Assert.AreEqual(dd.GetCardSet("Ac Kc"), NormRank.Convert(dd.GetCardSet("Ac Kd"))); Assert.AreEqual(dd.GetCardSet("Ac Kc"), NormRank.Convert(dd.GetCardSet("Ad Kc"))); Assert.AreEqual(dd.GetCardSet("Ac Kc"), NormRank.Convert(dd.GetCardSet("As Kh"))); Assert.AreEqual(dd.GetCardSet("3c 3d"), NormRank.Convert(dd.GetCardSet("3c 3d"))); Assert.AreEqual(dd.GetCardSet("3c 3d"), NormRank.Convert(dd.GetCardSet("3c 3h"))); Assert.AreEqual(dd.GetCardSet("3c 3d"), NormRank.Convert(dd.GetCardSet("3s 3h"))); Assert.AreEqual(dd.GetCardSet("2c 3c 3d 4c 4d 4h 6c 6d 6h 6s"), NormRank.Convert(dd.GetCardSet("2d 3s 3h 4c 4h 4d 6s 6d 6h 6c"))); }