Archived

This topic is now archived and is closed to further replies.

Visual C++ Poker Game Needed

This topic is 5909 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am a newbee C++ Programmer, and really need a basic 5 card draw poker game (not video poker). If anyone can help me out with this, I''d really appreciate it! I have found all kinds of JAVA poker games, but none in C++.

Share on other sites
what do you need it for?

--- krez (krezisback@aol.com)

Share on other sites
I am in my first C++ class and have been putting in 20+ hours a week in homework - just to keep up. A very complex variation of this poker game is to be the final project - of which I have no clue where to start.

Our teacher has 10+ years of coding experience, but no teaching experience. I know he is trying, but I am not catching on quick enough (no review or in-class exercises).

I work full-time as a programmer in 2 other languages (Associates Degree with 3.75 GPA), but cannot ''get'' this one. Everyone in the class is lost.

I think if I have just the base to start with, I should be OK to add in the rest of the functionality by researching other textbooks. With this base - I will need to add in the computer partner, other types of games (5 card stud etc), variations on the way the game is dealt, etc etc.

So far we have not even covered files (i/o modules) at all, and have just started working with classes and such. The class is over with in a month. We will not have any class-time to work on this - nor can we team up to split up the work. I know most are just going to blow off the project and hope for the best - but I think this will be a good learning opportunity - if I can actually compile something like this and walk through it. Then I can add in the functionality, and get a better understanding of how this language should work.

If anyone can help with this, I would really appreciate it. I usually pick up these types of things very quickly, and was hoping to be able to use this language in my job. But now I am just hoping to pass the class. I will then need to go back and try to teach myself with some on-line tutorials or something before I will be able to use it.

Share on other sites
quote:
Original post by Anonymous Poster
I work full-time as a programmer in 2 other languages (Associates Degree with 3.75 GPA), but cannot ''get'' this one.

No offense, but what languages are those? If they aren''t methodologically similar then the knowledge sometimes becomes a hinderance because you expect similarity. Again, this may not refer to you, but my point is that there isn''t necessarily a correlation.

That said, I personally know of no source code poker games, but I do recommend you search at SourceForge. Also, if your class is only just being introduced to classes this late in the semester, perhaps you should complain to the appropriate authorities so you are properly compensated and so you aren''t graded based on what you haven''t been taught.

I wanna work for Microsoft!

Share on other sites
A similar thing once happened with a new instructor in the intro C++ course at my university. Every student (And there were 100-150 of them) was offered a free retake of the class, after enough complained to administration.

Share on other sites
i will write the program for you if you mail me your degree.

--- krez (krezisback@aol.com)

Share on other sites
I dont know if this would help or not (are you having problems learning the C++ syntax, do you know C?), but I would approach it like this:

* Start by creating a ''Card'' class, which stores only the value and the suit (enum)

* Maybe have a ''Deck'' class which is obviously 52 ''Cards'', and is used to make sure no duplicate cards are dealt. Probably have one function "Shuffle"

* Then have a ''Hand'' class, which has 5 ''Cards'', and functions like "ReplaceCardFunction", "FillHandFunction" (from the ''Deck'') and "HowGoodIsMyHandFunction", etc.

Then the actual program is arbitrary, create an instance of ''Deck'' and x amount of ''Hands'' and it''s a piece of cake. This program is really easy in C, using arrays and structures, but since your class is C++ you are no doubt expected to use classes, which makes it a little tricky with the interactions between classes. I have done this in C and had no trouble, except the AI was the biggest hassle (what should I go for: 3 of a kind or a straight? should IK keep the 5 of clubs or not?)

Share on other sites
quote:
Original post by Ibanez
I have done this in C and had no trouble, except the AI was the biggest hassle (what should I go for: 3 of a kind or a straight? should IK keep the 5 of clubs or not?)

actually, it isn''t that bad (theoretically; i haven''t tried it yet but listen anyway)...
there are tables available of the probability of each hand turning up, which you could code into the program. the computer AI would have an advantage, as it could easily remember which cards were already seen, to adjust the probabilities (even without "cheating"; it would just have a perfect memory).
Then, it could weigh the bet versus the probability it will get the good hand versus the probability the other player(s) hand(s) being better.

--- krez (krezisback@aol.com)

Share on other sites
quote:
Original post by Anonymous Poster
A similar thing once happened with a new instructor in the intro C++ course at my university. Every student (And there were 100-150 of them) was offered a free retake of the class, after enough complained to administration.

Actually that is exactly what is going on now. I hope something can be done. Last night I talked with an analyst in our class (who programs in about 7 different languages) who is also lost. So I don''t feel quite so incompetent now. I am hoping for the best.

Share on other sites
there are tables available of the probability of each hand turning up, which you could code into the program. the computer AI would have an advantage, as it could easily remember which cards were already seen, to adjust the probabilities (even without "cheating"; it would just have a perfect memory).
Then, it could weigh the bet versus the probability it will get the good hand versus the probability the other player(s) hand(s) being better.

--- krez (krezisback@aol.com)

I have no clue what you are talking about when you refer to "AI". That has not been addressed in our class yet either. Could you elaborate on this topic?

Share on other sites
quote:
Original post by dointhings
I have no clue what you are talking about when you refer to "AI". That has not been addressed in our class yet either. Could you elaborate on this topic?

I''ll help. "AI" is the formal (though often colloquially used) term for a program or piece of code that a) simulates intelligent behavior (often in a limited context); or b) can be consider "conscious" - capable of learning and extrapolating information (from which it may in turn learn more) from any inputs it is given, amongst other attributes. The first term is what is more commonly referred to as the second is still more of an experimental science.

In a game where the player (user) competes against or faces simulated opposition from the computer, the term AI refers to the set of algorithms that determine the response offered by the computer. In this case, how the computer selects which cards to keep or discard, what hand to hope for, whether to "bluff" and so forth. In many cases, the simulation of behavior is reduced to randomized selection among cases of given probability of occurence. For example, say we played a pick a color (out of 3 possible colors - red, green and blue) game, and 4 out of 10 times I chose blue (say it was my favorite color), while I chose red and green 3 out of 10 times each. Then to simulate my choosing patterns, you would need to psuedorandomly select blue 40% of the time. A common method of selection is the C/C++ code below:
int choice = rand() % 10;// we''ll assume all numbers have an equal possibility of occurenceif (choice < 4){  // select blue; // choice is 0 - 3}if (choice < 7){  // select red; // choice is 4 - 6}else{  // select green; // choice is 7 - 9}

I hope that was useful information. Ai will not be a part of your curriculum, because artificial intelligence is not language specific. It is a computer science topic that involves behavioral scientists at times, as well as linguists (natural language sythesists), sociologist and so forth.

I wanna work for Microsoft!

Share on other sites
Isn''t AI going a little overboard for a beginner level class?
All you probably need is a game that would support multiple human players on the same computer.
I wrote a blackjack game not long ago. If you want I can mail you my CARD and DECK classes to take a look at, not copy (it is your assignment). By default I think I use 5 decks but that is very easily changed.

Remember the whole idea behind C++ is the ability to break apart problems into smaller problems. Instead of worrying about making the whole game first worry about making a deck of cards you can output, then worry about shuffling them, then worry about dealing (not for poker, just the ability to take the next card).
Then write a video poker game, that way you can test your poker and betting logic with only one player. When all that works try to add the ability to add more players. Then if you have time try to add the ability to have computer players.

Also check out Planet Source Code they have alot of good stuff.

Jason Mickela
ICQ : 873518
E-Mail: jmickela@sbcglobal.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------