IGNORED

# Jacks or Better (Video Poker)

## Recommended Posts

I reviewed the video footage of the show again and found another one if this hasn't been fixed already. Should this be a straight?

- James

##### Share on other sites

1 hour ago, ZeroPage Homebrew said:

I reviewed the video footage of the show again and found another one if this hasn't been fixed already. Should this be a straight?

- James

Hi James. From what I’ve read on the rules of video poker, a straight must include 5 cards of consecutive value, regardless of suit. If that hand was 9H/10S/JS/QS/KD or KD/QS/JS/10S/9H it would be a straight. Because they are not in consecutive order, it’s not a straight. If you or anyone can point me to a rule book online that states otherwise I can change it, I’m not professing to be an expert here.

##### Share on other sites

I'm re-posting v1.14, the earlier version was corrupted.  Renaming to v1.15 to avoid confusion. This version includes three new checks for variations of two pairs that weren't being checked for previously.

Regarding the detection of a straight or straight flush, I believe I've got the code correct but I can change it if I'm misinterpreting a rule.

Here's the logic I'm using in the game to check for a straight/straight flush with descriptions rather than the code itself:

;
;Check for a Straight or a Straight Flush
;
; 1. An ordered sequence is a straight if it does not contain doubles and if the difference in value between the first and last cards is 4.
;  My card values:  A=14, K=13, Q=12, J=11, 10=10, 9=9, 8=8, 7=7, 6=6, 5=5, 4=4, 3=3, 2=2
;  3/4/5/6/7, diff is 4 | 7/6/5/4/3 diff is 4 | A/K/Q/J/10 diff is 4 | A/2/3/4/5 diff is 9 (special case)
;
; 2. Aces can be high or low, but cannot wrap around (K-A-2-3-4).
;
; 3. It's not a straight if cards 2,3 or 4 are an Ace.
;
; 4. A straight can only be made if the player has a 5 or 10.
;
; 5. There can be no pairs.
;
; 6. Check and special-case the wheel (A2345), the difference is 9 rather than 4
;
;   if ( highest rank card == ACE )
;     Check if other 4 cards are
;           K, Q, J, 10
;       or  2, 3, 4, 5
;
; 7. The cards cannot all be the same suit or it's a straight flush, not a straight.
;
; 8. Check the hand for a sequence of cards...
;     - If all 5 suits match, this would be a straight flush         (Matching Suits)
;     - If any of the cards are different suits, it would be a flush (Non-Matching Suits)
;

• 1
• 1
##### Share on other sites

More specific for Jacks or Better:

## Jacks or Better Rules

Jacks or Better rules are fairly simple to learn, and is one of the simplest versions of Video Poker. In order to get a winning payout, your hand needs to include Jacks or better cards. It’s also one of the first, if not the first, variation to Video Poker. Similar to Poker, the objective is to achieve the strongest possible hand. With Jacks or Better, you get an extra point for every pair of Jacks or higher you receive. You can also play up to 100 hands at a time, therefore the more hands you bet with, the greater your potential winnings will be.

The game begins as soon as you place a bet on the machine. Afterwards, you will be dealt five cards, and will need to decide which cards to discard, if any, in hopes to get a better hand. Speaking of which, below are all the different hand values.

• High – A card that is a Jack or higher. For example, a Jack, Queen, King or Ace.
• Pair – two cards that have the same number. For example, two Kings.
• Two Pair – two pairs of cards that have the same number. For example, two 3s and two 6s.
• Three of a Kind – three cards that have the same number. For example, three 8s.
• Straight – similar to the Straight Flush except the five cards do not have to have the same suit. They just need to go in sequential order.
• Four to a Straight Flush – is when you’ve dealt four out of the five cards needed to complete a straight flush.
• Flush –five cards that have the same suit.
• Full House – is a hand that has both a three of a kind as well as a pair. For example, three Aces and two 5s.
• Four of a Kind – four cards that have the same number. For example, four Queens or four 10s.
• Straight Flush – five cards that go in sequential order and all have the same suit. For example, 2, 3, 4, 5, 6 all suited as hearts.
• Three to a Royal Flush – when you have three of the cards necessary to complete a Royal Flush.
• Four to a Flush – when you have four cards of the same suit.
• Four to a Straight – four cards that are in sequential order.
• Three to a Straight Flush – Three cards in sequential order with the same suit.
• Two to a Royal Flush – Two cards away from reaching a Royal Flush.
• Royal Flush – is the strongest and highest paying hand you can get. It’s a hand containing five cards with the same suit that go in order from 10 to Ace. For example, 10, Jack, Queen, King and Ace with all of them being suited with hearts.

## Jacks or Better Tips

Once you have learned all the rules to the game and feel confident, you should go ahead and learn some Jacks or Better tips that can help you become a better player. This way you’ll understand what to do for each hand you’ve received. Speaking of which, below we’ve prepared some tips on what you should do for the cards you’ve been dealt. If you haven’t been dealt any of the following hands below, go ahead and replace all five of the cards you’re holding by discarding them.

• Never try to reach another hand if you’ve already been dealt one of the following: Full House, Three of a Kind, Four of a Kind or Two Pair.
• Never give up a High Pair for a hand that’s four to a Flush or four to a Straight.
• Hang on to a Low Pair, even if you have three cards to a Straight Flush or four cards to a Straight.
• If you’ve been dealt four cards away from a Royal Flush, go ahead and discard the fifth card, no matter what.
• If the initial cards you’ve been dealt are a Flush or a Straight, go ahead and keep those hands unless you’re only one card away from reaching a Royal Flush.
• Keep in mind that a Three of a Kind, a Flush, a High Pair and a Straight are all stronger hands than three cards that are leading up to a Royal Flush. Only stick with a three cards leading to a Royal Flush if you have lower ranked hands like a Low Pair or four to a Flush.
• Unless you’re holding four cards to a Straight Flush, or four cards to a Royal Flush, you should always stick with a High Pair you’ve been dealt.
• 1
• 1
##### Share on other sites

Thanks Trebor.

The description of a straight does confirm what I assumed, however it doesn't specifically state that the cards cannot wrap around.  As the code is written now, a flush CANNOT wrap around, thus 56789 is a straight but 89567 is not, even though they are in sequential order when you wrap the numbers.

I found it mentioned here, a random page from berkeley.edu, it was the first hit on google:

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).

I am checking for the special case of A/2/3/4/5 already, and the other case with an Ace, A/K/Q/J/10, is naturally checked for already in the code because the card value difference between the A and the 10 is four.

##### Share on other sites

1 hour ago, Atarius Maximus said:

The description of a straight does confirm what I assumed, however it doesn't specifically state that the cards cannot wrap around.  As the code is written now, a flush CANNOT wrap around, thus 56789 is a straight but 89567 is not, even though they are in sequential order when you wrap the numbers.

I found it mentioned here, a random page from berkeley.edu, it was the first hit on google:

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).

I was under the same impression regarding a Straight after reading this:

Quote

Straight– This is a hand with five cards in sequence, for example 2, 3, 4, 5, 6. Once again it doesn’t matter what the suit is and the Ace can be used at either the beginning or end of a sequence.

I have not seen it mentioned that Ace usage in the middle is acceptable for a Straight.  Indeed, no "wrap around".

##### Share on other sites

Straights, Straight Flushes, and Royal Flushes do not need to be ordered on the screen to be counted (i.e.: 1C,2S,3D,4D,5H). The order being stated in the rules just pertains to your hand containing cards that have consecutive order/values. It's not talking about their position on the screen. So, as long as you have a 1C, 2S, 3D, 4D, and 5H card in your hand (for instance), they can be in any position in your hand to count as a straight (i.e.: 3D, 1C, 4D, 5H, and 2S would count as a straight). By doing it the way you are now, you're lowering the chances of getting any of these types of hands drastically. Straights of any kind are difficult enough to get in draw poker without any wild cards. The method you're using makes them nigh to impossible.

The game is supposed to mimic real poker (except that it is for a single hand of cards, here, rewarded by value of the hand), which cares not about the order in which cards are dealt to a player. Neither does it care about the order cards are in when you lay them down at the end of a game (to see which player has won). This would introduce something that doesn't exist in normal poker -- and I'm sure is not intended for video poker either. The only reason they show them in order in the examples is because it's easier to see what they're trying to explain. Notice how they also show all pairs and trips next to each other in the example hands. These cards do not need to appear next to each other in order to count for pairs or trips.

Here's an example from a real machine (I'm sure I can find more too).

[2nd Edit]

Here's one with a normal straight.

##### Share on other sites

Really cool! Do you have an S-video mod? If you do, can you send me details on said S-video mod or where I can get my 7800 modded? I still use stock RF and it's why I don't use 320C with ICT. It would look bad on my 7800. I decided on using 160B for ICT2 and then 160A form the enemy sprites to save on Cart space since my game will be 128K. (128KB with 16KB RAM and a POKEY)

##### Share on other sites

Nice game though, impressive work hiding the color limitations! ?

##### Share on other sites

6 hours ago, MrFish said:

Straights, Straight Flushes, and Royal Flushes do not need to be ordered on the screen to be counted (i.e.: 1C,2S,3D,4D,5H). The order being stated in the rules just pertains to your hand containing cards that have consecutive order/values. It's not talking about their position on the screen. So, as long as you have a 1C, 2S, 3D, 4D, and 5H card in your hand (for instance), they can be in any position in your hand to count as a straight (i.e.: 3D, 1C, 4D, 5H, and 2S would count as a straight). By doing it the way you are now, you're lowering the chances of getting any of these types of hands drastically. Straights of any kind are difficult enough to get in draw poker without any wild cards. The method you're using makes them nigh to impossible.

The game is supposed to mimic real poker (except that it is for a single hand of cards, here, rewarded by value of the hand), which cares not the order in which cards are dealt to a player. Neither does it care about the order cards are in when you lay them down at the end of a game (to see which player has won). This would introduce something that doesn't exist in normal poker -- and I'm sure is not intended for video poker either. The only reason they show them in order in the examples is because it's easier to see what they're trying to explain. Notice how they also show all pairs and trips next to each other in the example hands. These cards do not need to appear next to each other in order to count for pairs or trips.

Here's an example from a real machine (I'm sure I can find more too).

[2nd Edit]

Here's one with a normal straight.

Thanks for the explanation and the images, MrFish.  I should be able to fix this by programmatically putting the cards in order before evaluating them.  My issue now is ROM space, I've got some work to do on cleanup first.

##### Share on other sites

2 hours ago, Ecernosoft said:

Really cool! Do you have an S-video mod? If you do, can you send me details on said S-video mod or where I can get my 7800 modded? I still use stock RF and it's why I don't use 320C with ICT. It would look bad on my 7800. I decided on using 160B for ICT2 and then 160A form the enemy sprites to save on Cart space since my game will be 128K. (128KB with 16KB RAM and a POKEY)

Not sure who you're asking here.  I have 2 7800's, one with an AV mod and one without.  My real-hardware pics are using my 7800 with the standard RF output.  I don't know who would currently be able to help with a mod on the forums.  I used Joe at ElectronicSentimentalities (the link seems to no longer work), I shipped my console to him and he modded it for me. He used the latest and greatest Longhorn Engineering A/V board mod at the time, I had that done back in 2015.  Best Electronics may still offer it as well, but I believe you have to buy a console from them as well.  Someone else may be able to give you more current information.

##### Share on other sites

10 minutes ago, Atarius Maximus said:

Thanks for the explanation and the images, MrFish.  I should be able to fix this by programmatically putting the cards in order before evaluating them.  My issue now is ROM space, I've got some work to do on cleanup first.

No problem.

##### Share on other sites

Lots of behind the scenes changes here at the expense of removing most of the initial logo/intro sequence, it just briefly shows the AA Logo now.  I may change that back if I can find any other code I can further optimize, but for now I'm just testing the detection code.  All the DMA holes are stuffed and I only have about 40 bytes remaining in the 48k ROM.

Wrap around values are now detected, and I individually tested winning hands for each combination by forcing certain cards to appear.  This is the version I'm currently play testing, so far so good... but I'm going to keep playing, testing, and playing some more.

##### Share on other sites

Utilizing 1.19, this should have been a "Straight" win:

##### Share on other sites

1 hour ago, Trebor said:

Utilizing 1.19, this should have been a "Straight" win:

Thanks for sharing that, Trebor, that's very helpful.  I ran that exact same hand through my debug version and it reported cards 04 - 05 - 07 - 06 - 08, cards 3 and 4 were not sorted properly and should have been swapped.  So it's a problem with the sorting code that I added.  I should be able to review and fix that.

Steve

##### Share on other sites

I'm pretty sure I've got the sorting figured out now.  To make it easier to test and make changes, I wrote a separate utility that tests only that.  Every combination of numbers I've changed the initial values to have sorted properly.  Next I'll have to squeeze the sorting function into the game itself.

I'll go ahead and share the utility in case the code helps someone out in the future.  It displays 5 initial values of 5-4-3-2-1, the bubble sort function runs four passes continuously, and the 4th and final pass should always show the values sorted in ascending order.  You can change the initial values to sort with the joystick and fire button.

Note that this is definitely not the most optimal method to sort numbers.  I enjoy the challenge of attacking it like I would have originally, sitting in front of my Commodore 64 as a 12 year old, with no manuals, no help, and relying almost completely on if...then statements for logic calculations.   I had fun figuring this out today.

To compile you'll have to update the code and point to a copy of an atascii and scoredigits file, both come with the 7800 distribution in samples\samplegfx.

For reference, this is how a bubble sort works:

Take an array of numbers "5 1 4 2 8", and sort the array from lowest number to greatest number using bubble sort. In each step, elements written in bold are being compared. Three passes will be required for this example.

First Pass
( 5 1 4 2 8 ) → ( 1 5 4 2 8 ), Here, algorithm compares the first two elements, and swaps since 5 > 1.
( 1 5 4 2 8 ) → ( 1 4 5 2 8 ), Swap since 5 > 4
( 1 4 5 2 8 ) → ( 1 4 2 5 8 ), Swap since 5 > 2
( 1 4 2 5 8 ) → ( 1 4 2 5 8 ), Now, since these elements are already in order (8 > 5), algorithm does not swap them.
Second Pass
( 1 4 2 5 8 ) → ( 1 4 2 5 8 )
( 1 4 2 5 8 ) → ( 1 2 4 5 8 ), Swap since 4 > 2
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )

Now, the array is already sorted, but the algorithm does not know if it is completed. The algorithm needs one additional whole pass without any swap to know it is sorted.  The maximum number of passes a bubble sort needs is n-1, so for 5 values you'd need a minimum of four passes to sort all 5 numbers.

Third Pass
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )
( 1 2 4 5 8 ) → ( 1 2 4 5 8 )

##### Share on other sites

I added the new sorting code to the game.  I played 100 hands this evening and didn't see any problems - no false positives and no winning hands that weren't correctly identified. I managed to hit every hand except for a royal flush and a straight flush.  I did test those too by forcing those hands and the detection worked as expected.  It's still possible there's an issue somewhere so I'm going to keep playtesting.

I was experimenting with some different colors for this version.  I thought it would fit the poker theme better if I used more shades of green and yellow, like a poker table.  I may change my mind, but I kind of like how it looks.  Changing colors is easy, deciding which ones to use isn't.

I'm attaching the latest version and a screenshot (before I changed the colors) of my results after 100 hands.

Edit:  I see now that the total winning hands does not equal the "Hands Won" total.  It's inconsequential to the game, but I'll take a look at testing and fixing that.

##### Share on other sites

I fixed the "hands won" counter, but did come across another bug with detecting winning hands.  I'm pulling my hair out over this one, I've spent at least 8 hours on a seemingly simple fix that I just can't get to work.  There are rare circumstances where the game will falsely report a straight, and when I fix it, it then no longer reports a straight when it's supposed to.  The math/logic behind it simply isn't working like I'd expect.

I'm not going to post the latest version as it has known issues.  Hopefully I'll get this figured out soon, this really is the last remaining item to fix.

##### Share on other sites

Ok, I think I've got the winning hand detection bug worked out, and the hands won counter now works properly.  The timing is important on calling the different subroutines that check for winning hands, and I found that If I use a pause timer between them it effectively solves the problem.  Because winning hand detection is based on a frame counter now, I'm not sure if it will break running on a PAL system with the slight timing difference.  Also, it's only been tested on the A7800 emulator, I haven't played with the Concerto or CC2 yet.  I ran through over 100 hands again with this build and it worked perfectly, but as always I need to do more just to make sure.

One minor thing that is not a bug but is noticeable nonetheless happens on a winning hand.  You will see the "Better luck next time" and "You Lose" flash on the screen for a brief moment before it switches over to the proper "You win" text.  Again because of how winning hand detection works in the main loop I can't seem to solve that problem, and believe me I spent hours on that one minor little thing.  It may just stay in the final version.

Anyway, here's the latest build that I'm playtesting now.

##### Share on other sites

Just some cosmetic changes in this version. I'm getting around to a few things that were at the bottom of my list.  I haven't played all that much since yesterday, but still no further bugs found in the game.

• The backs of the cards now have the AA Logo
• Changed some colors
• A few minor revisions to sprites
• Changed some graphics and colors on the Statistics screen
•

##### Share on other sites

Here's the latest source code.

• 2
• 1
##### Share on other sites

Nice job using 320 mode to it's best! All though it looks best in-game.

##### Share on other sites

• 1 month later...

Very nice job! I'm now inspired to go back and revisit the "High Card Draw" and revise it to be Blackjack with all of the additional gameplay.

##### Share on other sites

• 2 weeks later...
On 7/20/2022 at 3:55 PM, Atarius Maximus said:

You just arrived at your favorite casino, and threw \$40 into the video poker machine.  Maybe today's the day you walk away with more than you came with?

I've spent the last few weeks working on a Jacks or Better poker game.  It's a WIP, but it's at a state now that it's playable so I wanted to share it.  There may be some bugs (more play testing is needed), and I'm planning on changing and/or adding some sound effects, graphics, and colors.  I have not yet tested this on real hardware.

I'm sure everyone knows how to play this game, but I'll run through some simple instructions anyway.

You start the game with 160 coins displayed in the bottom middle of the screen (\$40 in quarters!).  You can play until you run out of coins.  At the top of the screen your credits are displayed, the object is to get as many credits as you can with the 160 credits you start with.  If you wind up with more than 160, you're doing great!

When you start the game, you first need to make your bet.  You can bet up to four coins at once, and the payouts are highlighted at the top of the screen.  After the initial draw, you can't change your bet.  With the "Bet" button highlighted, press the fire button to cycle between 1-4 coins per hand.  Once you've chosen your bet, push right and push the fire button with "Draw" highlighted.  5 cards will be presented.  Here you can choose to hold or drop each card.  Select HOLD with the left fire button and DROP with the right fire button.  After you have made your choices, push down to go back to the "Draw" button and push fire.  Your hand will be analyzed for a win.  After winning or losing that hand, the "New Hand" button will be highlighted.  Push fire to start with 5 new cards.

Enjoy!  Please give me some feedback & suggestions if you play!

Edit: v1.35 *should* be the final version.

Steve

Version 1.35 Screenshots:

Old Versions:

Source Code:

Older v0.36 Screenshot:

Hey, since you are using 320 modes, I'd reccomend you check out 320BI. It's a special mode I made that emulates 320B with 320A. And you can even use a third color WITHOUT paring it with a C2 or C3 pixel. However, C3 is a combination of C1 and C2, so if you have red and blue, C3 would be purple.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.