Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Help Thread
#15
Fiel Wrote:Sorry about the double post, but this irked me.

When you're looking for a straight, there are a limited number of straights that can exist. And a straight must always be through a line (unless you want a weird straight like Q K A 2 3). So I think it would be far better to do this

PSEUDOCODE:

Code:
hand = GetHand()
numCardsInStraight = 0
cardTypes = [2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A]
For eachCardType in cardTypes:
   if eachCardType in hand:
       numCardsInStraight += 1
   else:
       numCardsInStraight = 0

   if numCardsInStraight == 5:
      return True
return False

I don't know if this helps you with your problems, but it's a different way to approach it in a much more logical manner than checking next and previous cards in an array.

I see. It's essentially the same approach I used for determining quads, trips, full houses and other stuff: the unique number of occurrences of a certain target.
So just to be clear on the idea, you will start the "combo" count, for lack of better words, once an eachCardType in the array of length 13 can be found in the hand, then increment it each time that event takes place again, terminate once it is false (so that 2, 3, 4, 5, 8 don't make a straight) and start a new count again, which will never reach the desired number 5.
Am I reading that right?

I'll have to think of a way to deal with A, 2, 3, 4, 5 in that case though. It gives ultimately the same output but I much prefer it since I don't have to change the hand that was supposed to be randomly generated.
Reply


Messages In This Thread
Coding Help Thread - by Kalovale - 2011-05-21, 11:11 PM
Coding Help Thread - by Tykian - 2011-05-21, 11:18 PM
Coding Help Thread - by Kalovale - 2011-05-21, 11:30 PM
Coding Help Thread - by Spaz - 2011-05-22, 12:28 AM
Coding Help Thread - by Unauthorized Intruder - 2011-05-22, 12:34 AM
Coding Help Thread - by Kalovale - 2011-05-22, 12:40 AM
Coding Help Thread - by Fiel - 2011-05-22, 01:18 AM
Coding Help Thread - by Fiel - 2011-05-22, 01:44 AM
Coding Help Thread - by Kalovale - 2011-05-22, 01:52 AM
Coding Help Thread - by Luacake - 2011-05-22, 01:43 PM
Coding Help Thread - by Kalovale - 2011-05-23, 06:26 PM
Coding Help Thread - by Fiel - 2011-05-23, 10:47 PM
Coding Help Thread - by Kalovale - 2011-05-23, 11:14 PM
Coding Help Thread - by Fiel - 2011-05-23, 11:48 PM
Coding Help Thread - by Kalovale - 2011-05-24, 03:07 AM
Coding Help Thread - by Stereo - 2011-05-24, 04:05 AM
Coding Help Thread - by Kalovale - 2011-05-26, 10:11 AM
Coding Help Thread - by Fiel - 2011-05-26, 12:39 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)