public void Test_HandToToKind() { DeckDescriptor deck = StdDeck.Descriptor; Assert.AreEqual(HePocketKind._AQo, HePocket.HandToKind(deck.GetIndexes("Ac Qd"))); Assert.AreEqual(HePocketKind._AQo, HePocket.HandToKind(deck.GetIndexes("As Qc"))); Assert.AreEqual(HePocketKind._22, HePocket.HandToKind(deck.GetIndexes("2s 2c"))); Assert.AreEqual(HePocketKind._32s, HePocket.HandToKind(deck.GetIndexes("2s 3s"))); Assert.AreEqual(HePocketKind._32s, HePocket.HandToKind(deck.GetIndexes("3c 2c"))); }
public void Test_KindToHand() { DeckDescriptor deck = StdDeck.Descriptor; int[] hand = HePocket.KindToHand(HePocketKind._AA); Assert.AreEqual(deck.GetIndexes("Ac Ad").ToArray(), hand); hand = HePocket.KindToHand(HePocketKind._KQo); Assert.AreEqual(deck.GetIndexes("Kc Qd").ToArray(), hand); hand = HePocket.KindToHand(HePocketKind._54s); Assert.AreEqual(deck.GetIndexes("4c 5c").ToArray(), hand); }
public void Test_SD3_UnnormalizedAdaptive() { Props parameters = XmlSerializerExt.Deserialize <Props>(Path.Combine(_testResDir, "ca-hssd-km.xml")); parameters.Set("SdKind", "Sd3"); parameters.Set("NormalizeHandValues", "false"); parameters.Set("MinBucketCounts", "8 10 10 1"); parameters.Set("MaxBucketCounts", "8 10 10 4"); parameters.Set("ClusterSizes0", "0 0.05 0.05 0.05"); parameters.Set("ClusterSizes1", "0 2 2 0"); HsSdKMeansAdaptiveCa ca = CalculateCa(parameters, new int[] { 0, 5000, 5000, 200 }, 1); VerifyPreflopPockets(ca); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; // In comments there are normalized values. #region Preflop bucket 3 (87s) //------------------------------------------------------------ // 0.572431087493896 0.380353838205338 hand = dd.GetIndexes("7d 8d 5d 5h 4d"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); // 0.57322484254837 0.173631072044373 hand = dd.GetIndexes("7c 8c 7s 2s As"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ #endregion #region Buckets 4,9,9 (adapted to one cluster, make sure min and max hs go to the same bucket 0) // Min hs // 0.953535377979279 0 hand = dd.GetIndexes("5h 5s 3s 5c 3d 2c 3c"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); // Max hs // 1 0 hand = dd.GetIndexes("5h 5s 3d 5d 5c Jc 2h"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ #endregion }
void VerifyPreflopPockets(HsSdKMeansAdaptiveCa ca) { DeckDescriptor dd = StdDeck.Descriptor; int[] hand; hand = dd.GetIndexes("Ac Ah"); Assert.AreEqual(7, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ac Kc"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ac Kh"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("5s 5h"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("7s 8s"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("8s 7d"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("7c 2d"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Qc 2d"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); }
public void Test_CalculateFast() { DeckDescriptor dd = StdDeck.Descriptor; int[] hand; float[] hssd; // Compare with values calculated by another implementation. hand = dd.GetIndexes("Kh Kd"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.SdPlus1); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.0620, hssd[1], 0.00005); hand = dd.GetIndexes("4s 3s"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.SdPlus1); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.2029, hssd[1], 0.00005); hand = dd.GetIndexes("Ac Ah"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.Sd3); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.1060, hssd[1], 0.00005); hand = dd.GetIndexes("7c 6c 8c 5c Ad"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.SdPlus1); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.2377, hssd[1], 0.00005); hand = dd.GetIndexes("7c 6c 8c 5c Ad"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.Sd3); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.3908, hssd[1], 0.00005); hand = dd.GetIndexes("7c 6c 8c 5c Ad Qs"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.Sd3); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.4038, hssd[1], 0.00005); hand = dd.GetIndexes("9d 9h 2c Qs Ah"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.SdPlus1); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.0805, hssd[1], 0.00005); hand = dd.GetIndexes("9d 9h 2c Qs Ah"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.Sd3); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.1273, hssd[1], 0.00005); hand = dd.GetIndexes("9d 9h 2c Qs Ah Ks"); hssd = HsSd.CalculateFast(hand, HsSd.SdKind.SdPlus1); Assert.AreEqual(HandStrength.CalculateFast(hand), hssd[0], 0.00005); Assert.AreEqual(0.1125, hssd[1], 0.00005); }
public void Test_GetBucket_PreflopPocket() { string bucketCounts = "8 7 6 5"; HsRangeCa b = CalculateHsRangeCa(bucketCounts, new int[] { 0, 1000, 1000, 1000 }, false); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; hand = dd.GetIndexes("7c 2d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6d 5d"); Assert.AreEqual(1, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ac Ah"); Assert.AreEqual(7, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("3d 2c"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); }
public void Test_CanLose() { DeckDescriptor d = StdDeck.Descriptor; Assert.IsFalse(HeHelper.CanLose(d.GetIndexes("Ac Ad Ah As 2c 2d 3c"))); Assert.IsFalse(HeHelper.CanLose(d.GetIndexes("7c 2d Ah Kh Qh Jh Th"))); Assert.IsTrue(HeHelper.CanLose(d.GetIndexes("7c 2d Kh Qh Jh Th 9h"))); Assert.IsTrue(HeHelper.CanLose(d.GetIndexes("7c 2d Th 9h 8h 7h 6h"))); Assert.IsFalse(HeHelper.CanLose(d.GetIndexes("Jh Qh Th 9h 8h 7h 6h"))); Assert.IsFalse(HeHelper.CanLose(d.GetIndexes("7h 3s Ac Ks Qd Js Tc"))); Assert.IsTrue(HeHelper.CanLose(d.GetIndexes("7h 3s Ks Qd Js Tc 9h"))); Assert.IsTrue(HeHelper.CanLose(d.GetIndexes("Ac Ad Ah Kc Kd 7c 3h 2s"))); }
public void Test_GetBucket_PreflopPocket() { string minBucketsCounts = "8 1 1 1"; string maxBucketsCounts = "8 7 6 5"; HsKMeansAdaptiveCa b = CalculateCa(minBucketsCounts, maxBucketsCounts, "0.1 0.1 0.1 0.1", new int[] { 0, 1000, 1000, 1000 }, false); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; hand = dd.GetIndexes("7c 2d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6d 5d"); Assert.AreEqual(1, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ac Ah"); Assert.AreEqual(7, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("3d 2c"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); }
public void Test_Indexes() { DeckDescriptor dd = new DeckDescriptor("TestDeck", _cardNames1, _cardSets1); Assert.AreEqual(0, dd.GetIndex("Q")); Assert.AreEqual(1, dd.GetIndex("K")); Assert.AreEqual(2, dd.GetIndex("A")); Assert.AreEqual(new int[] {}, dd.GetIndexes("")); Assert.AreEqual(new int[] { 2 }, dd.GetIndexes("A")); Assert.AreEqual(new int[] { 1, 2 }, dd.GetIndexes("K A")); Assert.AreEqual(new int[] { 2, 1 }, dd.GetIndexes("A K")); Assert.AreEqual(new List <int>(), dd.GetIndexesAscending(new CardSet { bits = 0x0 })); Assert.AreEqual(new List <int>(new int[] { 0 }), dd.GetIndexesAscending(new CardSet { bits = 0x1 })); Assert.AreEqual(new List <int>(new int[] { 0, 2 }), dd.GetIndexesAscending(new CardSet { bits = 0x11 })); }
public void Test_GetAbstractCard() { Props parameters = XmlSerializerExt.Deserialize <Props>(Path.Combine(_testResDir, "ca-hssd-ahvo-km.xml")); HsSdAhvoKMeansAdaptiveCa ca = CalculateCa(parameters, new int[] { 0, 5000, 5000, 5000 }, 1); VerifyPreflopPockets(ca); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; // In comments there are normalized values to verify in debugger. #region Preflop bucket 7 (AA) //------------------------------------------------------------ // 0.61537 0.42559 0.09124 hand = dd.GetIndexes("Ac As Kh 5h 2d"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); // 0.63778 0.43364 0.35852 hand = dd.GetIndexes("Ad As 7s 7h 5s"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length)); #endregion #region Preflop bucket 7 (AA), flop bucket 4 hand = dd.GetIndexes("Ac Ah Td Jh Js 5h"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length - 1)); // 0.647707503 0.222747622 0.335863970 Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ad Ah 5d 5s Ks 2d"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length - 1)); // 0.642999891 0.228836240 0.187371225 Assert.AreEqual(7, ca.GetAbstractCard(hand, hand.Length)); #endregion #region Preflop bucket 7 (AA), flop bucket 4, turn bucket 6 hand = dd.GetIndexes("Ac Ad 2h Qd Qh 3s 2s"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length - 2)); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length - 1)); // 0.20689665 0.00000000 0.44819598 Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("Ad Ah Qd Th Td 7c Jd"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length - 2)); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length - 1)); // 0.22068975 0.00000000 0.16117185 Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); #endregion }
public void Test_GetBucket() { string bucketCounts = "8 7 6 5"; HsRangeCa b = CalculateHsRangeCa(bucketCounts, new int[] { 0, 1000, 1000, 1000 }, false); DeckDescriptor dd = StdDeck.Descriptor; int [] hand; // Preflop hand = dd.GetIndexes("Ac Ah"); Assert.AreEqual(7, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("7c 2d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("3d 2c"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Flop hand = dd.GetIndexes("Ac Ah As Ad 2h"); Assert.AreEqual(6, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d As Ks Qh"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Turn hand = dd.GetIndexes("Ac Ah As Ad 2h 2d"); Assert.AreEqual(5, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6c 7c 3c 4c 5c As"); Assert.AreEqual(5, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d As Ks Qh 9d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // River hand = dd.GetIndexes("Ac Ah As Ad 2h 2d Qh"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6c 7c 8d 4c 5c As 8c"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d As Ks Qh 9d 6h"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Runner - runner hand = dd.GetIndexes("8c 7c"); Assert.AreEqual(2, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("8c 7c Ad Qc Jd"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("8c 7c Ad Qc Jd 4c"); int abstrCard = b.GetAbstractCard(hand, hand.Length); Assert.IsTrue(0 < abstrCard && abstrCard < 5, "Not worst, not best"); hand = dd.GetIndexes("8c 7c Ad Qc Jd 4c 5c"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); }
public void Test_SD3_Normalized() { Props parameters = XmlSerializerExt.Deserialize <Props>(Path.Combine(_testResDir, "ca-hssd-km.xml")); parameters.Set("SdKind", "Sd3"); parameters.Set("NormalizeHandValues", "true"); HsSdKMeansAdaptiveCa ca = CalculateCa(parameters, new int[] { 0, 5000, 5000, 200 }, 1); VerifyPreflopPockets(ca); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; // In comments there are normalized values. #region Preflop bucket 3 (87s) //------------------------------------------------------------ // 0.16 0.788 hand = dd.GetIndexes("7d 8d 2c 2d 6h"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.16 0.68 hand = dd.GetIndexes("7d 8d 2s Qd Qs"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.16 0.56 hand = dd.GetIndexes("7h 8h Qd Ah Ad"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ // 0.11 0.71 hand = dd.GetIndexes("7c 8c 2s Kd 6h"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.11 0.59 hand = dd.GetIndexes("7c 8c Ad 4h 4s"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.11 0.46 hand = dd.GetIndexes("7c 8c Qd Th As"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ // 0.50 0.88 hand = dd.GetIndexes("7s 8s 6h As Ts"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); // 0.50 0.38 hand = dd.GetIndexes("7d 8d Jh 8h Ts"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ // 0.577 0.859 hand = dd.GetIndexes("7h 8h 9h 6h Kc"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); // 0.577187135837646 0.401744224876062 hand = dd.GetIndexes("7c 8c Jd 8h Kc"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); // 0.582738543555089 0.344213514625024 hand = dd.GetIndexes("7d 8d As 5h 7s"); Assert.AreEqual(7, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ #endregion #region Preflop bucket 5 (87s), flop bucket 5 // 0.128810521694117 0.951043885127019 hand = dd.GetIndexes("7s 8s 6s 5d 5s 3c"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); // 0.123812857602944 0.945352984446005 hand = dd.GetIndexes("7d 8d 5d 6d 6h 3h"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); // 0.12485890128187 0.867666738688815 hand = dd.GetIndexes("7d 8d 9d 5d 2s 9h"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.12416155385214 0.778243250977976 hand = dd.GetIndexes("7d 8d 9c 3d Jd Jc"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); #endregion #region Preflop bucket 5 (87s), flop bucket 6 // 0.472642274513544 0.88830932502117 hand = dd.GetIndexes("7d 8d 7s Td Jh Qd"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); // 0.470875730450598 0.598779490375814 hand = dd.GetIndexes("7s 8s Qh 8c Kd Qd"); Assert.AreEqual(4, ca.GetAbstractCard(hand, hand.Length)); // 0.473583403574426 0.456663796438368 hand = dd.GetIndexes("7c 8c Kd Ts 8s 2c"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); #endregion #region Preflop bucket 5 (87s), flop bucket 5, turn bucket 3 // 0 0 hand = dd.GetIndexes("7d 8d 5d 6d 2c 6c 3c"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); // 0.0370182536334441 0 hand = dd.GetIndexes("7c 8c 4c 6s 6c 9s 3h"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); // 0.0491886423862399 0 hand = dd.GetIndexes("7c 8c 6c 5s 2c 5d Qd"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); // 0.103955376812209 0 hand = dd.GetIndexes("7c 8c 4c 6s 6c 9d As"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.122210952460597 0 hand = dd.GetIndexes("7c 8c 4c 9c Jh 5d Qh"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.615618648734274 0 hand = dd.GetIndexes("7c 8c 6c 9c 4s Kd 7d"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.806288057566463 0 hand = dd.GetIndexes("7h 8h 4h Th 6s Tc 8c"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.946247475857973 0 hand = dd.GetIndexes("7h 8h 4h Th 6s 3d 6h"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); // 1 0 hand = dd.GetIndexes("7d 8d 5d 6d 2c Jc 4d"); Assert.AreEqual(3, ca.GetAbstractCard(hand, hand.Length)); #endregion }
public void Test_SDPlus1_Normalized() { Props parameters = XmlSerializerExt.Deserialize <Props>(Path.Combine(_testResDir, "ca-hssd-km.xml")); parameters.Set("SdKind", "SdPlus1"); parameters.Set("NormalizeHandValues", "true"); HsSdKMeansAdaptiveCa ca = CalculateCa(parameters, new int[] { 0, 5000, 5000, 200 }, 1); VerifyPreflopPockets(ca); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; // In comments there are normalized values. #region Preflop bucket 3 (87s) //------------------------------------------------------------ // 0.124870985344431 0.63508321643425 hand = dd.GetIndexes("7h 8h 3h 3d 5d"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.125807666466134 0.516141338712588 hand = dd.GetIndexes("7d 8d Jh 5s Kc"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.124111506282763 0.417079457241485 hand = dd.GetIndexes("7c 8c Qd 9h As"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); //------------------------------------------------------------ #endregion #region Preflop bucket 5 (87s), flop bucket 2 // 0.135108591362915 0.296108827079204 hand = dd.GetIndexes("7c 8c As Jh 5h Ah"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.135741421452917 0.202453184066334 hand = dd.GetIndexes("7c 8c Qs 3c As Td"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); // 0.371952468197259 0.700541397123714 hand = dd.GetIndexes("7h 8h Ah Ad 9c Td"); Assert.AreEqual(6, ca.GetAbstractCard(hand, hand.Length)); // 0.368155487657242 0.848327075079798 hand = dd.GetIndexes("7s 8s Kd 6c 6s 2s"); Assert.AreEqual(5, ca.GetAbstractCard(hand, hand.Length)); #endregion #region Preflop bucket 5 (87s), flop bucket 2, turn bucket 5 // 0.617032410239351 0 hand = dd.GetIndexes("7c 8c Kd As 3c 4c 7d"); Assert.AreEqual(2, ca.GetAbstractCard(hand, hand.Length)); // 0.0250783709388574 0 hand = dd.GetIndexes("7c 8c Ah Kd 5c 2c 6h"); Assert.AreEqual(0, ca.GetAbstractCard(hand, hand.Length)); // 0.100313477974807 0 hand = dd.GetIndexes("7c 8c 4s Ah Ts 6d Ad"); Assert.AreEqual(1, ca.GetAbstractCard(hand, hand.Length)); #endregion }
public void Test_GetBucket() { // Fix number of buckets to get exact abstract cards. string minBucketsCounts = "8 7 6 5"; string maxBucketsCounts = "8 7 6 5"; HsKMeansAdaptiveCa b = CalculateCa(minBucketsCounts, maxBucketsCounts, "0.1 0.1 0.1 0.1", new int[] { 0, 1000, 1000, 1000 }, false); DeckDescriptor dd = StdDeck.Descriptor; int[] hand; // Preflop hand = dd.GetIndexes("Ac Ah"); Assert.AreEqual(7, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("7c 2d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("3d 2c"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Flop hand = dd.GetIndexes("Ac Ah As Ad 2h"); Assert.AreEqual(6, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d As Ks Qh"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Turn hand = dd.GetIndexes("Ac Ah As Ad 2h 2d"); Assert.AreEqual(5, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6c 7c 3c 4c 5c As"); Assert.AreEqual(5, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d 7s 5s Qh 9d"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // River hand = dd.GetIndexes("Ac Ah As Ad 2h 2d Qh"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("6c 7c 8d 4c 5c As 8c"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("2c 3d As Ks Qh 9d 6h"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); // Runner - runner hand = dd.GetIndexes("8c 7c"); Assert.AreEqual(2, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("8c 7c Ad Qc Jd"); Assert.AreEqual(0, b.GetAbstractCard(hand, hand.Length)); hand = dd.GetIndexes("8c 7c Ad Qc Jd 4c"); int abstrCard = b.GetAbstractCard(hand, hand.Length); Assert.IsTrue(0 < abstrCard && abstrCard < 5, "Not worst, not best"); hand = dd.GetIndexes("8c 7c Ad Qc Jd 4c 5c"); Assert.AreEqual(4, b.GetAbstractCard(hand, hand.Length)); }