Drawing Cards and Video Poker
|
04-02-2020, 02:33 PM
(This post was last modified: 04-02-2020 02:36 PM by Eddie W. Shore.)
Post: #1
|
|||
|
|||
Drawing Cards and Video Poker
The Function drawcardfx
The function drawcardfx draws a set number of cards from a deck of 52 standard playing cards. To achieve this effect, I made four lists: List 1: A list of all integers 0 to 51. List 2: The suits. I took each of the elements of List 1 MOD 4, giving the answers of 0, 1, 2, 3, respectively. Each of the modulo are assigned to a suit: 0: Clubs. This is character 9827 for the HP Prime. ♣ 1: Diamonds. This is character 9826. (9827 - 1) ♢ 2: Hearts. This is character 9825. (9827 - 2) ♡ 3: Spades. This is character 9824. (9827 - 3) ♠ List 3: The ranks. I divided each element of List 1 by 4, take the integer part, then add 1. For example: for card number 17: IP(17/4) + 1 = IP(4.25) + 1 = 4 + 1 = 5. This is why I let List 1 range for 0 to 51 instead of 1 to 52, since IP(52/4) + 1 = 14 while IP(0/4) + 1 = 1, and I want four 1s, four 2s, four 3s, up to four 13s. There are 13 ranks in a standard deck of cards. List 4: This list starts empty and will hold all the cards drawn in the hand. Empty lists are allowed in the HP Prime. I then turned List 2 and List 3 into appropriate strings. For List 3, I turned each 1 into an Ace (A), 11 into a Jack (J), 12 into a Queen (Q), and 13 into a King (K). The While loop allows me to pull to generate a sample with no repeats. If there is an easier way for me to do this on the HP Prime, please let us in the comments. The function returns a list of strings in the format "(rank) (suit)". Example: drawcardfx(5) might return {"K ♠", "9 ♡", "A ♠", "4 ♢", "K ♣"} (not bad, pair of Kings) HP Prime Program: drawcardfx Code:
A Simple Video Poker Program The program VIDEOPOKER is simple video poker program. You are dealt a hand of 5 cards from a standard 52 card deck. You are then asked to hold every card that you want to keep. Once you decide which cards to keep, that card is held. Executing the DRAW option redraws the cards and you are shown your final hand. This is a very simple program because there is no better or ranking of hands. This just has the play of the cards. The game is achieved by having the game draw 10 cards in advance, separating them into groups of 5. This program will require the function drawcardfx above. Example Game: Run VIDEOPOKER - no arguments needed. Your first hand: 6 ♢ 5 ♢ 10 ♠ Q ♠ 6 ♡ A choose box appears after I press [ Enter ]. Let's say I want to hold the pair of sixes. So I highlight each of the sixes and press [ Enter ]. After doing this the choose box now reads: HOLD? HELD 5 ♢ 10 ♠ Q ♠ HELD DRAW I now choose draw and I get: ------------------ Final hand: 6 ♢ A ♠ 4 ♢ 6 ♣ 6 ♡ I improved my hand to a set of sixes (three sixes). HP Prime Program VIDEOPOKER Code:
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)