Advertisement
Guest User

Hand Evaluator PocketHands.cs Bug FIx

a guest
Aug 10th, 2013
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/Hand Evaluator/HandEvaluator/PocketHands.cs b/Hand Evaluator/HandEvaluator/PocketHands.cs
  2. index 2bf5c76..8172f7b 100644
  3. --- a/Hand Evaluator/HandEvaluator/PocketHands.cs  
  4. +++ b/Hand Evaluator/HandEvaluator/PocketHands.cs  
  5. @@ -3958,7 +3958,7 @@ namespace HoldemHand
  6.          static public PocketHands PocketCards169(string pocket)
  7.          {
  8.              PocketHands retval = new PocketHands();
  9. -            if (pocket.Length == 3 && pocket[2] == '*')
  10. +            if ((pocket.Length == 2 && pocket[0] != pocket[1]) || (pocket.Length == 3 && pocket[2] == '*'))
  11.              {
  12.  
  13.                  retval |= _Pocket169Combinations[(int)Pocket169(string.Format("{0}{1}s", pocket[0], pocket[1]))];
  14. @@ -4151,7 +4151,7 @@ namespace HoldemHand
  15.          static public PocketHands PocketCards169Range(string s, string e)
  16.          {
  17.              Hand.PocketHand169Enum smin, smax, emin, emax;
  18. -            if (s.Length == 3 && s[2] == '*')
  19. +            if ((s.Length == 2 && s[0] != s[1]) || (s.Length == 3 && s[2] == '*'))
  20.              {
  21.                  smin = Pocket169(string.Format("{0}{1}s", s[0], s[1]));
  22.                  smax = Pocket169(string.Format("{0}{1}o", s[0], s[1]));
  23. @@ -4161,7 +4161,7 @@ namespace HoldemHand
  24.                  smin = smax = Pocket169(s);
  25.              }
  26.  
  27. -            if (e.Length == 3 && e[2] == '*')
  28. +            if ((e.Length == 2 && e[0] != e[1]) || (e.Length == 3 && e[2] == '*'))
  29.              {
  30.                  emin = Pocket169(string.Format("{0}{1}s", e[0], e[1]));
  31.                  emax = Pocket169(string.Format("{0}{1}o", e[0], e[1]));
  32. @@ -4193,21 +4193,16 @@ namespace HoldemHand
  33.          static public PocketHands PocketCard169Range(Hand.PocketHand169Enum s, Hand.PocketHand169Enum e)
  34.          {
  35.              PocketHands retval = new PocketHands();
  36. -            int start = (int) s, end = (int) e;
  37. -            if (start > end)
  38. -            {
  39. -                for (int i = end; i <= start; i++)
  40. -                {
  41. -                    retval |= _Pocket169Combinations[i];
  42. -                }
  43. -            }
  44. -            else
  45. +            int start = Math.Min((int)s, (int)e);
  46. +            int end = Math.Max((int)s, (int)e);
  47. +            // If the start and end are both suited or both offsuited, just return suited/offsuited pockets.
  48. +            int interval = start > 12 && start % 2 == end % 2 ? 2 : 1;
  49. +
  50. +            for (int i = start; i <= end; i += interval)
  51.              {
  52. -                for (int i = start; i <= end; i++)
  53. -                {
  54. -                    retval |= _Pocket169Combinations[i];
  55. -                }
  56. +                retval |= _Pocket169Combinations[i];
  57.              }
  58. +
  59.              return retval;
  60.          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement