Advertisement
Guest User

PocketHands.cs Bug Fix

a guest
Aug 10th, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. diff --git a/Hand Evaluator/HandEvaluator/PocketHands.cs b/Hand Evaluator/HandEvaluator/PocketHands.cs
  2. index 2bf5c76..7f03a9f 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,17 +4193,21 @@ 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. + int start = Math.Min((int)s, (int)e);
  38. + int end = Math.Max((int)s, (int)e);
  39. + // If the start and end are both suited or both offsuited, just return suited/offsuited pockets.
  40. + int interval = start > 12 && start % 2 == end % 2 ? 2 : 1;
  41. +
  42. if (start > end)
  43. {
  44. - for (int i = end; i <= start; i++)
  45. + for (int i = end; i <= start; i += interval)
  46. {
  47. retval |= _Pocket169Combinations[i];
  48. }
  49. }
  50. else
  51. {
  52. - for (int i = start; i <= end; i++)
  53. + for (int i = start; i <= end; i += interval)
  54. {
  55. retval |= _Pocket169Combinations[i];
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement