This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-13 16:00:21

JimmyBallax
New Scratcher
Registered: 2010-07-13
Posts: 1

Texas Holdem Card Hand Rankings

I have started trying to make a simple poker game, but have hit a big problem, i have no idea how to make it recognise the different hands in poker and then say which is best, this is easier for ones like high card, but for things like straight flush i have no clue. Please help

Offline

 

#2 2010-07-13 16:06:28

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Texas Holdem Card Hand Rankings

You could make lists for each type of successful hand, and compare it to the player's hand. (Assuming your hand is stored in a list.) Example: "If < (player's hand) = (full house) >"


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-07-13 17:13:31

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: Texas Holdem Card Hand Rankings

Hm - I have no idea what kinds of hands are involved in Poker, but I'd imagine it's something like Yahtzee. Take a look at my Yahtzee project for some quick reference, but be warned that cards are a largely different media.

Offline

 

#4 2010-07-13 19:04:31

fullmoon
Retired Community Moderator
Registered: 2007-06-04
Posts: 1000+

Re: Texas Holdem Card Hand Rankings

I would represent each card as a two-letter pair, i.e. QS for queen of spades or 7C for seven of clubs. Each of these card strings (which could be put into lists to represent a hand) contains both the suite and value of the card, identifiable using the (letter () of []) block. I would recommend sorting the list lowest to highest -- this could be tricky but you should be able to look at Jens' project Sort for examples. Now, finding pairs and threes-of-kind should be pretty easy; just look for duplicates in the hand list. With a straight, just keep checking the next card in the list to see if it is one higher than the last. A flush is simple: take the first card in the list and make sure the rest of the cards are of the same suite. Finally, you should store all this info for when it comes time to check who has won. I hope this post made some sort of sense -- I'm typing on my iPod so it's do
Ifficult to be coherent.


http://i302.photobucket.com/albums/nn100/fullmoon32/wow.jpg

Offline

 

#5 2010-07-21 00:48:52

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Texas Holdem Card Hand Rankings

Maybe if you put a special color code on each of the cards and made a sensor or a couple that went over each of the cards in your hand, it could determine what your hand is. For example, the cards from 2 to Ace each have seperate colors, so the system knows if it's touching red white and blue for example, you've got these 3 cards in your hand. It'd be tricky though if you have doubles. Maybe have a 3 of a kind censor, a 4 of a kind censor and a regular censor somehow? Also having something to arrange the cards in order from lowest to highest in your hand might work.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

Board footer