Thanks Larry
I sat down the other day and worked a lot of stuff out.
Best to worse TICK. dont that
Pairs, 3s, 4s, FH and flushes easy.
Straights not so, but I did some working out and managed it. Took me a good
three hours may I say.
My problem I got now though is when two players in my imaginary 4 player
game have both got same Pair for instance. I then need to weed out those two
card from the array and find the highest card left. What if they match so
then looking for next best card.
Ill get there. Its a good learning curve for me. Making me use the grey
matter that seems to have been rejected for sometime.
I do have another problem. I am using VS 2005 Beta 2. When i build and
publish the software no-one else seems to be able to install it. The error
says something along the lines. DotNetFX/WindowInstaller-KB884016-v2-x86.exe
has changed since it was initially published. I have tried adding the Dotnet
Framework to my distribute file also.
Someone suggested Bootstrapping. DOH!! Sorry I am a hobbiest and dont
understand.
Any ideas
MC
"Larry Lard" <la*******@hotmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
MC wrote: Hi guys
Been trawling for ages now!!
Anyone seen any code for working out the best 5 card hand from 7 cards as
in
Limit/No-Limit Poker.
You mean "as in Texas Hold 'em"
I am doing a project for myself to teach me .NET and struggling.
Thought i'd cheat a bit.
OK, so no complete answers from me :)
First, how are you modelling cards? I suggest a class or structure with
Suit and Rank methods that return values from Enums you define.
Check for each type of hand in turn, from best to worst - stop checking
when you get a match (a hand containing a three of a kind also contains
a pair, but we only care about the *best* match).
A lot of the hand checking is made easier by sorting the cards by rank.
To check for a straight, check for differences of one in appropriate
places.
If you find a straight, check the suits for a straight flush.
Checking for four of a kind is easy if the cards are rank sorted.
It might be useful to count the incidences of ranks. eg AAKQJJ7, count
the ranks, get an array like this:
(1): 2
(2): 0
...
(7): 1
...
(11): 2
(12): 1
(13): 2
With such an array, checking for FH / 3s / 2x2s / 2s is easy. A similar
suit-counting array makes checking for a flush very easy.
And that's it, really :)
--
Larry Lard
Replies to group please