Off Topic A place for you CBR junkies to boldly go off topic. Almost anything goes.

Computer Programming

Thread Tools
 
Search this Thread
 
  #11  
Old 11-24-2008, 02:01 PM
woo545's Avatar
Senior Member
Join Date: Jun 2007
Location: PA
Posts: 2,680
Likes: 0
Received 1 Like on 1 Post
Default RE: Computer Programming

Actually, I'm not being helpful at this point. Sorry. Maybe I was being a little dramatic on the size of this issue. For some reason I was thinking you were writing the AI and it occurred to me that this is not needed. Lets try again.

Break each step down in to its components. [ul][*]Determine Number of players[*]Shuffle cards (need storage of the cards and a random number generator of some sort to uniquely store each card)[*]Ante[*]Deal[*]Bet (Pre-flop)[*]Deal Flop (3 cards)[*]Bet[*]Deal Turn (1 Card)[*]Bet[*]Deal River (1 Card)[*]Bet[*]Showdown (evaluation of hands)[/ul]As you can see, the Betting interface can be reused. So, only write this once. Make sure you have storage setup for the shuffled deck of cards, each player`s 2 cards and the 5 community cards. Also have storage for the pot and each players bank.

Take each step and flow chart your logic. Also figure out winning combinations.

EDIT: This is actually doable. No graphical interface is really required beyond ASCII, but adding simple graphics should not be difficult by this point.
 
  #12  
Old 11-24-2008, 02:33 PM
rrasco's Avatar
Senior Member
Join Date: Mar 2006
Location: South Texas
Posts: 5,844
Likes: 0
Received 1 Like on 1 Post
Default RE: Computer Programming

PHP FTW!
 
  #13  
Old 11-24-2008, 06:02 PM
woot's Avatar
Senior Member
Join Date: Jul 2006
Location: NS, Canada
Posts: 1,127
Likes: 0
Received 1 Like on 1 Post
Default RE: Computer Programming

As long as you don't need to make AI players, it's not that hard... the two things to work on are the containers (a container of the cards, and a player's hand container), then the scoring module that ranks hands

What do you need to know? The logic of scoring? Simple - all you need to know is the different hand types - a run, a flush, a full house, 3 of a kind, double pair, pair, single card. Put them into a container or set of rules from high to low. Rank the hands. In the even that two players have equal high rank, then consider the high card in the primary scoring, then if that doesn't break the tie, consider the high card in the secondary score, etc. That can be a simple for loop for each test. It'd be good to be able to mark the cards so you don't use them twice in combinations... but if you have a hand container you could re-use that.

If I were going to use that latter option I'd even consider going the ungainly route. Making a card collection object that has a high card method, a score value, and a card count method. Then I'd make a copy of the 3 turned cards into the players hand. Then I'd have a function to split each players cards into scoring sets, re-using the card collection object. This would have to be a greedy algorithm, which conviently would be the easiest. Take the set of cards from the hand to the collection that makes the highest scoring set. Repeat with the remaining cards until the hand is empty. In a useless hand the worst case would be 5 single-ton collections. Then for each player I'd ask for the highest point set. If there was a tie - ie both had 3 of a kind, then I'd ask the collections for the high card in the set. In the event that the tie wasn't broken, then consider the second collection - repeat until the tie is broken, or you have no more collections - statistically near impossible.

I don't know poker well enough but here are the values I'm pretending - doesn't matter as long as they are in value order.
10 Flush
9 4 of a kind
8 Full-house
7 3 of a kind
6 two pair
5 pair
4 Singleton


That is what I'd try first. Best spot to start for me would be learning poker
 
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
redzintimidator
Off Topic
10
11-13-2023 09:31 AM
jp_greenville13
Off Topic
11
09-11-2010 03:19 PM
lkngood
F4i - Main Forum
0
01-25-2009 03:07 PM
timpeet
Off Topic
7
04-02-2007 12:37 PM



Quick Reply: Computer Programming



All times are GMT -5. The time now is 07:21 AM.