private void EvaluateHands() { foreach (var hand in _hands) { TwoPlusTwo.Evaluate(hand, _boardCards); } }
public static double[] GetHandPotential(Hand hand, Hand boardCards) { var ahead = 0; var tied = 1; var behind = 2; var array = TwoPlusTwo.HandPotential(hand, boardCards); var positivePotential = (array[0][behind, ahead] + array[0][behind, tied] / 2 + array[0][tied, ahead] / 2) / (array[1][0, behind] + array[1][0, tied]); if (double.IsNaN(positivePotential)) { positivePotential = 0; } var negativePotential = (array[0][ahead, behind] + array[0][tied, behind] / 2 + array[0][ahead, tied] / 2) / (array[1][0, ahead] + array[1][0, tied]); if (double.IsNaN(negativePotential)) { negativePotential = 0; } return(new[] { positivePotential, negativePotential }); }
public void Evaluate() { int value = TwoPlusTwo.EvaluateCards(this); Points = value; Rank = value & 0x00000fff; HandType = (HandType)((value >> 12) - 1); }
public static double GetHandStrength(Hand hand, Hand boardCards) { var array = TwoPlusTwo.HandStrength(hand, boardCards); var ahead = array[0]; var tied = array[1]; var behind = array[2]; return((ahead + tied / 2) / (ahead + tied + behind)); }
public static double[] HandStrength(int[] handNumbers, int[] boardNumbers) { var ahead = 0.00; var tied = 0.00; var behind = 0.00; for (var c0 = 1; c0 < 53; c0++) { if (!handNumbers.Contains(c0)) { var o0 = TwoPlusTwo.EvalCard(53 + c0); var h0 = TwoPlusTwo.EvalCard(53 + handNumbers[0]); var h1 = TwoPlusTwo.EvalCard(h0 + handNumbers[1]); var opponentNumbers = new int[7]; boardNumbers.CopyTo(opponentNumbers, 2); opponentNumbers[0] = c0; for (var c1 = 1; c1 < 53; c1++) { if (!handNumbers.Contains(c1) && !opponentNumbers.Contains(c1)) { var o1 = TwoPlusTwo.EvalCard(o0 + c1); var c2 = boardNumbers[0]; var o2 = TwoPlusTwo.EvalCard(o1 + c2); var h2 = TwoPlusTwo.EvalCard(h1 + c2); var c3 = boardNumbers[1]; var o3 = TwoPlusTwo.EvalCard(o2 + c3); var h3 = TwoPlusTwo.EvalCard(h2 + c3); var c4 = boardNumbers[2]; var o4 = TwoPlusTwo.EvalCard(o3 + c4); var h4 = TwoPlusTwo.EvalCard(h3 + c4); opponentNumbers[1] = c1; var comparedHands = CompareHands(h4, o4); if (boardNumbers.Length == 4) { var c5 = boardNumbers[3]; var o5 = TwoPlusTwo.EvalCard(o4 + c5); var h5 = TwoPlusTwo.EvalCard(h4 + c5); comparedHands = CompareHands(h5, o5); } if (comparedHands == 0) { ahead++; } else if (comparedHands == 1) { tied++; } else { behind++; } } } } } return(new[] { ahead, tied, behind }); }
public static double[][,] HandPotential(int[] handNumbers, int[] boardNumbers) { var handPotentialTotal = new[, ] { { 0.00, 0.00, 0.00 } }; var handPotential = new[, ] { { 0.00, 0.00, 0.00 }, { 0.00, 0.00, 0.00 }, { 0.00, 0.00, 0.00 } }; var ahead = 0; var tied = 1; var behind = 2; for (var c0 = 1; c0 < 53; c0++) { if (!handNumbers.Contains(c0)) { var o0 = TwoPlusTwo.EvalCard(53 + c0); var h0 = TwoPlusTwo.EvalCard(53 + handNumbers[0]); var h1 = TwoPlusTwo.EvalCard(h0 + handNumbers[1]); var opponentNumbers = new int[7]; boardNumbers.CopyTo(opponentNumbers, 2); opponentNumbers[0] = c0; for (var c1 = 1; c1 < 53; c1++) { if (!handNumbers.Contains(c1) && !opponentNumbers.Contains(c1)) { var o1 = TwoPlusTwo.EvalCard(o0 + c1); var c2 = boardNumbers[0]; var o2 = TwoPlusTwo.EvalCard(o1 + c2); var h2 = TwoPlusTwo.EvalCard(h1 + c2); var c3 = boardNumbers[1]; var o3 = TwoPlusTwo.EvalCard(o2 + c3); var h3 = TwoPlusTwo.EvalCard(h2 + c3); var c4 = boardNumbers[2]; var o4 = TwoPlusTwo.EvalCard(o3 + c4); var h4 = TwoPlusTwo.EvalCard(h3 + c4); opponentNumbers[1] = c1; var comparedHands = CompareHands(h4, o4); int o5 = 0; int h5 = 0; int index; if (boardNumbers.Length == 4) { var c5 = boardNumbers[3]; o5 = TwoPlusTwo.EvalCard(o4 + c5); h5 = TwoPlusTwo.EvalCard(h4 + c5); comparedHands = CompareHands(h5, o5); } if (comparedHands == ahead) { index = ahead; } else if (comparedHands == tied) { index = tied; } else { index = behind; } for (var c6 = 1; c6 < 53; c6++) { if (boardNumbers.Length == 3) { for (var c5 = 1; c5 < 53; c5++) { if (!handNumbers.Contains(c5) && !opponentNumbers.Contains(c5)) { handNumbers[5] = c5; opponentNumbers[5] = c5; o5 = TwoPlusTwo.EvalCard(o4 + c5); h5 = TwoPlusTwo.EvalCard(h4 + c5); if (!handNumbers.Contains(c6) && !opponentNumbers.Contains(c6)) { handPotentialTotal[0, index]++; var o6 = TwoPlusTwo.EvalCard(o5 + c6); var h6 = TwoPlusTwo.EvalCard(h5 + c6); comparedHands = CompareHands(h6, o6); if (comparedHands == ahead) { handPotential[index, ahead]++; } else if (comparedHands == tied) { handPotential[index, tied]++; } else { handPotential[index, behind]++; } } } } } else if (boardNumbers.Length == 4) { if (!handNumbers.Contains(c6) && !opponentNumbers.Contains(c6)) { handPotentialTotal[0, index]++; var o6 = TwoPlusTwo.EvalCard(o5 + c6); var h6 = TwoPlusTwo.EvalCard(h5 + c6); comparedHands = CompareHands(h6, o6); if (comparedHands == ahead) { handPotential[index, ahead]++; } else if (comparedHands == tied) { handPotential[index, tied]++; } else { handPotential[index, behind]++; } } } } } } } } return(new[] { handPotential, handPotentialTotal }); }