Computer Science Canada Poker Flush- I know there is a better way to do this |
Author: | berf [ Sat Jun 24, 2006 9:20 am ] | ||
Post subject: | Poker Flush- I know there is a better way to do this | ||
I know theres a better way to do this flush likely with arrays but I have a brain cramp and caan't think of how to do it. here is my code:
Please help me out on this one, and I'm also having trouble trying to figure out how to do straights, any hints on that would be great as well. thanks all |
Author: | Delos [ Sat Jun 24, 2006 11:37 am ] | ||
Post subject: | |||
Have you considered using types for this? It appears that you're using a 2-dim array, which isn't a bad idea, but types might help a little:
You would then create an initialization function to iniitialize all of the elements. If you use the 1-dim approach, you'll have to break down the init into 4 areas, one for each suit (read: nested for loops!). You could also opt for a 2-dim array (4x13) which would essentially mean the same thing but a little less maths. The use of having the 'suit' field means that for a flush, you would only consider that dimension in your analysis. For a straight, you'd only consider the 'value' field. And for a straight flush...! Good luck. |