Wager Mage
Photo by Alotrobo Pexels Logo Photo: Alotrobo

Can a straight go from 10 to ace?

An ace can be the lowest card of a straight (ace, 2, 3, 4, 5) or the highest card of a straight (ten, jack, queen, king, ace), but a straight can't "wrap around"; a hand with queen, king, ace, 2, 3 would be worthless (unless it's a flush).

Who is best player of football?
Who is best player of football?

Best football players of all time Alfredo Di Stefano. Alfredo Di Stefano. ... Franz Beckenbauer. Franz Beckenbauer. ... Johan Cruyff. Johan Cruyff....

Read More »
How much does a donk car cost?
How much does a donk car cost?

Pre-built donks get up into the $30,000 range, and some complete cars eclipse $100K. Mar 23, 2017

Read More »

Simply Scheme:Project: Scoring Poker Hands

Simply Scheme

Introducing Computer Science

Project: Scoring Poker Hands

The idea of this project is to invent a procedure poker-value that works like this: > (poker-value '(h4 s4 c6 s6 c4)) (FULL HOUSE - FOURS OVER SIXES) > (poker-value '(h7 s3 c5 c4 d6)) (SEVEN-HIGH STRAIGHT) > (poker-value '(dq d10 dj da dk)) (ROYAL FLUSH - DIAMONDS) > (poker-value '(da d6 d3 c9 h6)) (PAIR OF SIXES) As you can see, we are representing cards and hands just as in the Bridge project, except that poker hands have only five cards.[1] Here are the various kinds of poker hands, in decreasing order of value: • Royal flush: ten, jack, queen, king, and ace, all of the same suit • Straight flush: five cards of sequential rank, all of the same suit

• Four of a kind: four cards of the same rank

• Full house: three cards of the same rank, and two of a second rank

• Flush: five cards of the same suit, not sequential rank

• Straight: five cards of sequential rank, not all of the same suit • Three of a kind: three cards of the same rank, no other matches

• Two pair: two pairs of cards, of two different ranks

• Pair: two cards of the same rank, no other matches

• Nothing: none of the above

An ace can be the lowest card of a straight (ace, 2, 3, 4, 5) or the highest card of a straight (ten, jack, queen, king, ace), but a straight can't "wrap around"; a hand with queen, king, ace, 2, 3 would be worthless (unless it's a flush). Notice that most of the hand categories are either entirely about the ranks of the cards (pairs, straight, full house, etc.) or entirely about the suits (flush). It's a good idea to begin your program by separating the rank information and the suit information. To check for a straight flush or royal flush, you'll have to consider both kinds of information. In what form do you want the suit information? Really, all you need is a true or false value indicating whether or not the hand is a flush, because there aren't any poker categories like "three of one suit and two of another." What about ranks? There are two kinds of hand categories involving ranks: the ones about equal ranks (pairs, full house) and the ones about sequential ranks (straight). You might therefore want the rank information in two forms. A sentence containing all of the ranks in the hand, in sorted order, will make it easier to find a straight. (You still have to be careful about aces.) For the equal-rank categories, what you want is some data structure that will let you ask questions like "are there three cards of the same rank in this hand?" We ended up using a representation like this:

Who is highest scorer in football?
Who is highest scorer in football?

Cristiano Ronaldo Cristiano Ronaldo of Portugal has scored the most goals in men's international football with 118 goals in 191 games and counting....

Read More »
How much do I win if I bet $10 on?
How much do I win if I bet $10 on?

For example, if you bet $10 on 4.0 odds, the total amount returned on a winning wager would be $40 ($10x4). The potential profit is $30, or $10x4...

Read More »

> (compute-ranks '(q 3 4 3 4)) (ONE Q TWO 3 TWO 4) One slightly tricky aspect of this solution is that we spelled out the numbers of cards, one to four , instead of using the more obvious (1 Q 2 3 2 4) . The reason, as you can probably tell just by looking at the latter version, is that it would lead to confusion between the names of the ranks, most of which are digits, and the numbers of occurrences, which are also digits. More specifically, by spelling out the numbers of occurrences, we can use member? to ask easily if there is a three-of-a-kind rank in the hand. You may find it easier to begin by writing a version that returns only the name of a category, such as three of a kind , and only after you get that to work, revise it to give more specific results such as three sixes .

Extra Work for Hotshots

In some versions of poker, each player gets seven cards and can choose any five of the seven to make a hand. How would it change your program if the argument were a sentence of seven cards? (For example, in five-card poker there is only one possible category for a hand, but in seven-card you have to pick the best category that can be made from your cards.) Fix your program so that it works for both five-card and seven-card hands. Another possible modification to the program is to allow for playing with "wild" cards. If you play with "threes wild," it means that if there is a three in your hand you're allowed to pretend it's whatever card you like. For this modification, your program will require a second argument indicating which cards are wild. (When you play with wild cards, there's the possibility of having five of a kind. This beats a straight flush.)

(back to Table of Contents)

BACK chapter thread NEXT

Who is currently the highest paid NFL player?
Who is currently the highest paid NFL player?

Total Cash Aaron Rodgers. GB, QB. $59,515,000. Deshaun Watson. CLE, QB. $46,000,000. Patrick Mahomes. KC, QB. $40,450,000. Kyler Murray. ARI, QB....

Read More »
Can I bet both over and under?
Can I bet both over and under?

If you find two different totals at different sportsbooks, or the line moves enough, you have an opportunity to win both the over and the under...

Read More »
Does craps have the best odds in the casino?
Does craps have the best odds in the casino?

So from the Blackjack table, he suggests moving on to the dice game Craps, the game with the second best odds, also nearly 50-50. The Craps table...

Read More »
What happens to people who cheat at casinos?
What happens to people who cheat at casinos?

People who cheat and swindle their way toward large winnings are, in a sense, stealing from the casinos. Casinos will likely have their own...

Read More »