poker

Algorithm to determine the winner of a Texas Hold'em Hand

人走茶凉 提交于 2019-11-30 05:25:53
Ok, so I am making a Texas Hold'em AI for my senior project. I've created the gui and betting/dealing procedures, but I have reached the part where I need to determine who won the hand, and I do not know the best way to approach this. I am using python btw. ATM i have 2 lists, one for the 7 player cards, one for the 7 computer cards. Currently all cards are stored as a struct in the list as {'Number': XX, 'Suit': x}, where number is 2-14, suit is 1-4. The way I was going to approach this, is make a function for each hand type, starting with the highest. Eg. self.CheckRoyal(playerCards), and

Algorithm to give a value to a 5 card Poker hand

久未见 提交于 2019-11-30 04:48:29
问题 I am developing a poker game as college project and our current assignment is to write an algorithm to score a hand of 5 cards, so that the scores of two hands can be compared to each other to determine which is the better hand. The score of a hand has nothing to do with the probability of what hands could be made upon the draw being dealt with random cards, etc. - The score of a hand is based solely on the 5 cards in the hand, and no other cards in the deck. The example solution we were

Java Array Index Out of Bounds somehow?

爷,独闯天下 提交于 2019-11-29 18:36:34
In my game's code, I am trying to add a card to hand. As soon as I do, my array is out of bounds. Everything looks right, but maybe I'm missing something. FYI, one and two are Player instances. Relevant code from Main class (sorry about the formatting. i suck at transferring it to Stack Overflow): import java.util.*; public class Program { public static void main(String args[]) { String[] rank = {"two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king", "ace"}; String[] suit = {"hearts", "diamonds", "spades", "clubs"}; Scanner scan = new Scanner(System.in

On Two Plus Two poker hand evaluator, how do you get the best 5 cards combination out of the 7 that you passed to it?

余生长醉 提交于 2019-11-29 14:38:28
问题 Is it possible to extract that info from the equivalence value? I understand that the higher the equivalence value the better. Category and rank can also be extracted from the equivalence value. But is there a way to find out what the best 5 cards combination are from the 7 that you passed to it? Twoplustwo is the fastest poker hand evaluator around (14-15 million hands evaluated per second). You give your 7 cards to it and it spits out a hand equivalence value. The higher the value, the

Algorithm to determine the winner of a Texas Hold'em Hand

十年热恋 提交于 2019-11-29 03:47:21
问题 Ok, so I am making a Texas Hold'em AI for my senior project. I've created the gui and betting/dealing procedures, but I have reached the part where I need to determine who won the hand, and I do not know the best way to approach this. I am using python btw. ATM i have 2 lists, one for the 7 player cards, one for the 7 computer cards. Currently all cards are stored as a struct in the list as {'Number': XX, 'Suit': x}, where number is 2-14, suit is 1-4. The way I was going to approach this, is

Optimizing Lookups: Dictionary key lookups vs. Array index lookups

青春壹個敷衍的年華 提交于 2019-11-28 22:41:15
I'm writing a 7 card poker hand evaluator as one of my pet projects. While trying to optimize its speed (I like the challenge), I was shocked to find that the performance of Dictionary key lookups was quite slow compared to array index lookups. For example, I ran this sample code that enumerates over all 52 choose 7 = 133,784,560 possible 7 card hands: var intDict = new Dictionary<int, int>(); var intList = new List<int>(); for (int i = 0; i < 100000; i ++) { intDict.Add(i, i); intList.Add(i); } int result; var sw = new Stopwatch(); sw.Start(); for (int card1 = 0; card1 < 46; card1++) for (int

Java Array Index Out of Bounds somehow?

瘦欲@ 提交于 2019-11-28 13:14:02
问题 In my game's code, I am trying to add a card to hand. As soon as I do, my array is out of bounds. Everything looks right, but maybe I'm missing something. FYI, one and two are Player instances. Relevant code from Main class (sorry about the formatting. i suck at transferring it to Stack Overflow): import java.util.*; public class Program { public static void main(String args[]) { String[] rank = {"two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king",

The simplest algorithm for poker hand evaluation

試著忘記壹切 提交于 2019-11-28 03:51:32
I am thinking about poker hand (5 cards) evaluation in Java . Now I am looking for simplicity and clarity rather than performance and efficiency. I probably can write a "naive" algorithm but it requires a lot of code. I saw also a few poker evaluation libraries, which use hashing and bitwise operations, but they look rather complex. What is the "cleanest and simplest" algorithm for poker hand evaluation ? Here is a very short but complete histogram based 5 card poker scoring function in Python (2.x). It will get considerably longer if converted to Java. def poker(hands): scores = [(i, score

Algorithm to find streets and same kind in a hand

爷,独闯天下 提交于 2019-11-27 16:13:56
问题 This is actually a Mahjong-based question, but a Romme- or even Poker-based background will also easily suffice to understand. In Mahjong 14 tiles (tiles are like cards in Poker) are arranged to 4 sets and a pair. A street ("123") always uses exactly 3 tiles, not more and not less. A set of the same kind ("111") consists of exactly 3 tiles, too. This leads to a sum of 3 * 4 + 2 = 14 tiles. There are various exceptions like Kan or Thirteen Orphans that are not relevant here. Colors and value