473,806 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

evaluating strength of a poker hand

258 Contributor
Hi every one
I'm trying to make a little poker game but I don't know how to evaluate the strength of a 7 card hand..

It's not that hard with 5 cards. Actually I found some program to do that with 5 cards but the problem is that there is 5 flop cards and 2 cards that the player has in hand.

I don't even know how to start that .... (identify cards by numbers? 1 to 52) or (identify them by both numbers and suits)

Any suggestion will be helpful

Thanks
Jan 29 '08 #1
24 7086
kadghar
1,295 Recognized Expert Top Contributor
Hi every one
I'm trying to make a little poker game but I don't know how to evaluate the strength of a 7 card hand..

It's not that hard with 5 cards. Actually I found some program to do that with 5 cards but the problem is that there is 5 flop cards and 2 cards that the player has in hand.

I don't even know how to start that .... (identify cards by numbers? 1 to 52) or (identify them by both numbers and suits)

Any suggestion will be helpful

Thanks
no, just think the hand is an array (7,2)

where the first dimension is the card, and the second dimension will be (1 the suit, 2 the number)
so if you want someone to have a poker of A's and other 3 cards, it'll look like:

arr(1,1) = 1 , arr(1,2) = 1
arr(2,1) = 2 , arr(2,2) = 1
arr(3,1) = 3 , arr(3,2) = 1
arr(4,1) = 4 , arr(4,2) = 1
arr(5,1) = any suit , arr(5,2) = any number
arr(6,1) = any suit , arr(6,2) = any number
arr(7,1) = any suit , arr(7,2) = any number

i think the algorithm to check them wont be short, but it seems doable using some FOR to sum and some SELECT CASE
give it a try.

HTH
Jan 29 '08 #2
bnashenas1984
258 Contributor
Thanks for the reply
I realy need to get this program working as soon as possible.
I'll try to do it like you said.

Thanks again
Jan 29 '08 #3
kadghar
1,295 Recognized Expert Top Contributor
Thanks for the reply
I realy need to get this program working as soon as possible.
I'll try to do it like you said.

Thanks again
Good luck with that.

If you have any doubts while coding, we'll be glad to help you.
Jan 29 '08 #4
bnashenas1984
258 Contributor
Hi again kadghar and thanks for the help
It's working now.. I haven't tested the speed yet but it's working fine. the only hand I'm having problem with is full house..
I'm working on it. I hope I can fix it.

Thanks again
Jan 30 '08 #5
Killer42
8,435 Recognized Expert Expert
One method which would require a lot of initial setup but could work very fast is to define a seven-dimensional array. Assign a number to every one of the 52 cards. Then every element in the array would represent a possible hand, and would hold the score for that hand.

Hahaha... just realised, the downside is that I think there are a bit over a trillion (1,000,000,000, 000) possible hands. This might cause some minor difficulties related to (A) array size and (B) time required to populate it.

Well, I still think the idea was valid.

Hm... no wonder we don't see much multi-dimensional array usage.
Jan 30 '08 #6
daniel aristidou
491 Contributor
Hahaha... just realised, the downside is that I think there are a bit over a trillion (1,000,000,000, 000) possible hands. This might cause some minor
Hehe Minor.......... ..... only a few huh?
Jan 31 '08 #7
Killer42
8,435 Recognized Expert Expert
Hehe Minor.......... ..... only a few huh?
Sure. It's just a matter of throwing some huge quantities of money into RAM and processor power, and everything will be fine.

Plus, I suppose you might have to hire the population of India to enter the data.
Jan 31 '08 #8
bnashenas1984
258 Contributor
Thanks for posts
Actually my program is working fine now.. But there is a pronlem
I put cards information in an array like "deck(x,y)"
the first dimension shows the number of card and the other one shows the suit.
then i check for the strength
But I'm having problem with the speed. It's now 15,000 hands per second which is not enough for me
I think I need a faster way to sort the array.. The way I sort it takes long time. Does any of you know how to sort a 2 dimensional array in a fast way?

Thanks
Jan 31 '08 #9
kadghar
1,295 Recognized Expert Top Contributor
Thanks for posts
Actually my program is working fine now.. But there is a pronlem
I put cards information in an array like "deck(x,y)"
the first dimension shows the number of card and the other one shows the suit.
then i check for the strength
But I'm having problem with the speed. It's now 15,000 hands per second which is not enough for me
I think I need a faster way to sort the array.. The way I sort it takes long time. Does any of you know how to sort a 2 dimensional array in a fast way?

Thanks
do you mean sort, like with bubble sort, sorting the first dimension first and then the seccond?,

why dont you use something like (to sort a one dimension array):

arr1(1 to n) 'where n is the number of hands, and the array values are from 1 to 230, where 1 is a pair of two, and 230 a royal straight flush

so lets say your first hand was a pair of 5, so arr1(1) = 4, and your seccond hand was a royal straight flush, so arr1(2) = 230.

Here you can use a bubble sort, or a cocktail sort or any Sorting Algorithm. I'd say that once you have arr1, you will be able to sort more than 15,000 hands in a seccond.
Now, i bet the method that will fill this array, measuring the strength of the hands, is quite slower. May be you want to work with that.
Jan 31 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

35
2569
by: robert d via AccessMonster.com | last post by:
I was asked to provide a proposal. I provided a proposal on my application and the prospective client likes what I have but is wary of it having been developed in Access. I don't understand this concern since my front-end application will be linked to a SQL SERVER backend. But there seems to be this "conventional wisdom" among IT people that Access is a toy database. Okay, let's redefine that as "Jet" is a toy database (which I don't...
7
13272
by: ibtc209 | last post by:
I just started programming in C, and I need some help with this problem. Your program will read the information about one MiniPoker hand, namely the rank and suit of the hand’s first card, and the rank and suit of its second card. Note that the two cards in a hand may be entered in any order; it’s not necessarily the case that the highest card will appear first, for example. Your program will then determine whether the hand is valid, and...
1
4488
by: Martin Olsen | last post by:
Hi all. I am creating a program which calculates poker odds. The program should look at the visible cards (those on your hand and those on the table) then count the cards needed to improve the hand(eg. how many cards do I need to get a Flush) and then calculate the odds based on those numbers. My problem is that I do not know how I should find the missing cards. One way I could do it is to use programming logic like this
27
5633
by: Simon Biber | last post by:
I was reading http://en.wikipedia.org/wiki/Poker_probability which has a good description of how to count the frequency of different types of poker hands using a mathematical approach. A sample Python program is given in the discussion page for doing it that way. I wanted to take a different approach and actually generate all the possible hands, counting the number of each type. It's quite do-able on today's hardware, with 5-card...
1
3083
by: =?Utf-8?B?bWljcm9ob2Y=?= | last post by:
Short version: Is there a way to configure (preferably programmatically) the max encryption strength that will be used by the framework when connecting to a particular SSL-protected web service? Long version: Historically, browsers could only be exported to certain countries if they supported only 40 and 56 bit encryption; 128 bit was restricted. I believe, based on my readings thus far, that this refers to the strength of the...
15
6488
by: sandy123456 | last post by:
At the moment im trying to write a hand class for a game poker patientnce But when i get to the part having to catergorise the difference of full house straight flush flush four of a kind and straight i got stuck.I need to write boolean methods to return these (stright flush , four of a kind..etc) I can only do a pair and 2 pairs and three of a kind. The following is my code please someone if possible help me thanks import java.util.*; ...
13
2563
by: kinghippo423 | last post by:
Hello Everyone, I did a poker program in Java that essencially finds the strenght of a poker hand created Randomly. My program is doing OK...but I'm pretty sure it can be optimised. This is my results with 1 million hands: Number of hands generated : 1000000 Straight Flush : 0.0012 % In theory : 0.0012%
9
4691
by: teejayem | last post by:
I am looking for some help! I am currently developing a new game for an online community. The game is called Pokino which ishalf bingo and half poker. Wierd eh?! Anyway... The final part of the program needs to evaluate two 5 card poker hands and determine which one out of the two hands wins. I thought rather than create a new class of my own I would see if there was anything
7
5684
by: Extremity | last post by:
Hi, I am taking a intro to C++ course so my knowledge base only limits to areas such as if/else, functions, and recursions. We are creating a program which will determine the probability of Poker Hands, such as Royal Flush, Straight Flush, Four of a Kind and such. However in order to complete this, I need to determine how many different poker hands there are. On pencil and paper, this is relatively easy as its a simple combination problem. ...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.