Teen Programmers Unite  
 

 

Return to forum top

poker

Posted by Autism [send private reply] at May 04, 2002, 09:31:56 PM

What would be the best way to go about making a 5 card draw poker game?

Posted by Autism [send private reply] at May 04, 2002, 09:33:25 PM

language is C++ =P sorry

Posted by gian [send private reply] at May 05, 2002, 02:13:21 AM

You need an array to hold the "hand" of cards, and then a routine to go and look for matches (the easiest way to do that is to put them in order).

Posted by RedX [send private reply] at May 05, 2002, 06:51:03 AM

Start with an array with the 52 cards, The "card" needs 2 values: what card it is and a bool indicating if it's already used or not.
select for each player 5 random cards. You only need to know what card it is. Then apply the rules on those sets of cards. This can be done by a serie of searches. Sorting them first, like Gian said, can seriously speed this up. But it basicaly comes down to comparing numbers to find pairs, streets, etc.

RedX

Posted by AREM [send private reply] at May 05, 2002, 12:54:37 PM

Useing a "struct" would work pretty well. :)

Posted by buzgub [send private reply] at May 06, 2002, 01:05:19 AM

You should think about how you would divide the process of playing poker into smaller, easily written steps.

Posted by gian [send private reply] at May 06, 2002, 03:26:12 AM

A flowchart program like Visio can be very useful when planning out programs.

Posted by CodeMage [send private reply] at May 08, 2002, 10:57:35 AM

If you want to design your program thoroughly I would suggest using UML tools, like Rational Rose. I know it might be a serious overkill for something like poker, but the best way to learn is to do so on a small (read: not too complicated) project. And you can form some nice habits too :)

(hope I'm not generating too much noise here)

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.