Advertisement

Poker Game

Started by September 06, 2003 07:04 AM
7 comments, last by Legaceez 21 years, 4 months ago
i''m experimenting by making a little poker game. can anyone explain to me the basics of figuring out what your hand is? determining if its a flush, straight, full house, etc . . .
Here
Advertisement
Umbongo - Answer or shut up. Everyone always wants to link google. If you don't like the question, don't answer, it's that simple. A lot of other questions in these forums could be answered with google. This is a place to seek answers as well.

On to the answer. This isn't really a design question, but a programming question. Basically, you need to create a large if structure, starting with the highest hand.

If(card1.suit == card2.suit & card1.suit == card3.suit, etc )
hand = flush


And so on. Start with a royal flush and work your way on down. It won't look pretty, but that's the easiest way to do it.

[edited by - moonshot on September 6, 2003 12:52:42 PM]
moonshot aka Jayson Bailey
He go the answer he deserved. He should learn how to ask a question properly. First you research it yourself. He registered here to ask the question when a simple search would have returned the results instantly.

I also read the original question as "how do i play poker".

So why don't you keep your rude "answer or shut up" remarks to yourself.

[edited by - Umbongo on September 6, 2003 8:37:10 PM]
quote: Original post by moonshot
Umbongo - Answer or shut up. Everyone always wants to link google. If you don''t like the question, don''t answer, it''s that simple. A lot of other questions in these forums could be answered with google. This is a place to seek answers as well.

Not everyone is as willing as you to waste their time explaining something that the OP could research himself in ten seconds. "STFW" or similar is a courtesy to the OP, rather than just not replying.

How appropriate. You fight like a cow.
Well I''d have a Hand class with different sorts of functions like

- isStraight()
- isFlush()
- getLowPair()
- getHiPair()
- getTriplet()
- getQuadruplet()
- getLowCard()
- getHiCard()

etc etc

Then you could do what moonshot was talking about way more easily -

if (hand.isStraight() && hand.isFlush() && hand.getLowCard() = == 10) return ROYAL_FLUSH;
if (hand.getQuadruplet()) return FOUR_OF_KIND;

and so forth
Advertisement
quote: Original post by Sneftel
quote: Original post by moonshot
Umbongo - Answer or shut up. Everyone always wants to link google. If you don''t like the question, don''t answer, it''s that simple. A lot of other questions in these forums could be answered with google. This is a place to seek answers as well.

Not everyone is as willing as you to waste their time explaining something that the OP could research himself in ten seconds. "STFW" or similar is a courtesy to the OP, rather than just not replying.

How appropriate. You fight like a cow.


Explain to me how that is a courtesy. I think he''d rather you not say anything.
moonshot aka Jayson Bailey
quote: Original post by moonshot
Explain to me how that is a courtesy. I think he''d rather you not say anything.

Look, let''s say you post a question on GameDev as follows: "HI I WANT U TO TEACH ME C++ ILL WAIT HEAR." You will get the following responses:

1. Terse responses pointing you towards useful resources like google or ebooks.

2. People taking a while to actually teach the OP C++ in painstaking detail.

3. People who don''t reply.

As the OP, #2 would be nice, but since he clearly hasn''t put in any effort to find stuff for himself, it''s unlikely. Most of us here who know a good deal about our subject matter are more than willing to help people out (that''s why we''re here) but we learned by learning for ourselves, not by running to the message boards the minute we got confused. So generally the OP is going to get #3, and be no better off than when he started. #1 is a clue to the OP that we DID read his message, and aren''t ignoring him but rather think it would be a helpful experience for him to do some more research for himself.

Now, is this still unclear?

How appropriate. You fight like a cow.
My first game I programmed was a poker game, I was originaly supposed to make a card shuffling and dealing program but felt like modifying it to deal with hands, then continued to modify it until I finaly felt like I could play a game of poker on it.

My point though is knowing how to deal with the hands and find out what a hand holds is part of the programming and design for the game. Once you''ve been told how it sort of removes the point of making it =0.

But as a little bit of advice, try to make the game think like you would, at least that is what I did.

Its easy to make the game arrange a hand of 5 cards. Then run it through some comparing funcions. For example, Have it check for a pair by running it through a loop 4 times that checks the first card with the second the second with the third the third with the fourth with the fifth.

Also make sure to check for possible 3 and 4 of a kinds with each pass, so you don''t come out with 3 pairs because you have 4 of a kind(I got this on accident.)

The actual code would be something like-

for(int a = 0; a <= 3; a++)
{
if(cardArray[0] == cardArray[1] && cardArray[1] != cardArray[2])
pair++;

Of course that only checks for a 3 of a kind, but that should give you a hint as to what to do next.

Ask yourself these questions, Logicaly, How would you compare cards to see if a hand has a straight? a flush? full house?

This topic is closed to new replies.

Advertisement