✅ Texas holdem poker
Hi, I need help with my project to school. My task is to create Texas holdem poker. But I dont know how to find if players have one of the 10combinations.
I m getting random 9 cards from class "Card". Cards are 1-14(hearths), 101-114(spades), 201-214(clubs) and 301-314(diamonds).
player 1 have cards cards[5].Value and cards[6].Value
player 2 have cards cards[7].Value and cards[8].Value
on the table are cards cards[0].Value, cards[1].Value, cards[2].Value, cards[3].Value, cards[4].Value
and now, i dont know how to evaluate combinations.
If you need more informations text me.
thanks a lot!
3 Replies
read up on domain modeling. you shouldn't be using indexing directly in your code like that. either store them separately, or make getters for all player cards by player index, and all cards on board. don't store card values as just numbers — use a struct
and then supposedly an enum for values and an enum for the whatever the other thing is called
what are the combinations? if you have them listed, just check the cards against the list
When checking for combinations, you're going to want to start by checking for the best possible combination (royal flush), down to the worst (high card) in order. Each player will end up with 2 cards, with 3 on the river.
Read up on each type of hand if you don't know them already, then its just a matter of checking for value and suit. For example a royal flush is A, K, Q, J and 10 all in the same suit. You check that first because you want to use a player's best possible combination if that's the one that matches.
Just to make that point clear - For example, if you checked for three of a kind first, you could miss that someone has a full house if you stopped there.
Also, if you're dealing with card class instances, it does make sense to deal cards and store them inside of a player class, along with how much they're betting into the pot, and how much money they have to bet with. Though, it could make sense to store their bet elsewhere in the case of a split pot, haven't thought about it that far.
Hopefully that helped to some degree
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.