poker-hand-evaluator | small poker hand evaluator written in Java | Game Engine library
kandi X-RAY | poker-hand-evaluator Summary
kandi X-RAY | poker-hand-evaluator Summary
This is a small poker hand evaluator I wrote for fun. It allows you to work with poker cards and hands, especially to determine the values of hands. Note that there are much faster and more versatile evaluators for different sizes of hands. This is just a small project of mine, written for my own recreational purposes.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Returns the value of a given card
- Checks that the given array contains duplicates
- Returns the hash value for the given key
- Returns the card s value
- Returns a string representation of this card
- Returns the rank of the card
- Returns the suit of this card
- Create a new hand hand hand from a string
- Create a card instance from the given string
- Converts the given card array to a string
poker-hand-evaluator Key Features
poker-hand-evaluator Examples and Code Snippets
Community Discussions
Trending Discussions on poker-hand-evaluator
QUESTION
Consider sorted lists of length 7 where each entry x is a number 2 <= x <= 14 and the duplicate count of any entry can't exceed 4. The assumption here is that a high-performance algorithm has already determined that we have a non-straight / non-flush hand.
Online poker sites would be interested in high-performance algorithms taking care of the next step of getting the 5 best cards in this context.
Writing a program in Python that doesn't import modules is a great way to prototype such algorithms.
Most likely the 'monster size' online poker sites don't need any help from us, but it would be interesting to see algorithms designed for speed. In the question
from 2010 this was examined, but many links are broken. It would be nice to know the status of the fastest known algorithms used today.
Question: Is the algorithm discussed below known? Has some algorithm been determined to be a standout for performance?
My work
I noticed that a list of length 7 has a midpoint and that there is 'combinatorial symmetry' and structure that an algorithm can incorporate. We implement this logic in the following code. One can think of a lightening fast program written in assembler that calculates a GOTO
number offset with the solution.
Note: I also have a one-pass sort routine that takes any 7 cards and determines whether straight or flushes can be made. But I've been advised to keep my questions more focused, so that is not discussed here.
Python Program:
...ANSWER
Answered 2019-Feb-06 at 19:15Here are some thoughts you may consider when designing your algorithm for finding the best hand:
- The comparisons all deal with comparing the card value (number) and/or suit. So you may want to consider making a list of the card numbers and a list of the card suits. Or look at the tricks that the
itertools
module has. - Flush and straight flush are the only hands where the suit matters. Otherwise, you're only looking at the card numbers.
- Straight and straight flush are the only hands where you have to look for 5 consecutive numbers. Keep in mind that this can include aces and face cards. Also, if an ace is included then it must be at the start or the end (e.g., "Q K A 2 3" doesn't count as a straight). You may also want to look into the module more_itertools.consecutive_groups.
- The other hands (one pair, two pair, three of a kind, full house, four of a kind) are all based on how often same numbers appear. If a value appears 4 times, then there's no need to check for the other hands in this list. If one appears 3 times, then check if you can make a full house, otherwise it's a three of a kind. You can keep checking down this list like this from highest hand to lowest hand, stopping when you get a match.
- You may even consider making a class called
Card
, and feeding your cards in as objects of type "Card". Then you can have functions in the class to return the card's suit or numeric value.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install poker-hand-evaluator
You can use poker-hand-evaluator like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the poker-hand-evaluator component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page