HP Forums
(41) Game of Roulette - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: HP-41C Software Library (/forum-11.html)
+--- Thread: (41) Game of Roulette (/thread-17267.html)



(41) Game of Roulette - Gene - 07-20-2021 06:09 PM

From: 65 Notes V3N9P20 by Craig Pearce.

Register usage:
00 - unused
01 - unused
02 - player's total
03 - bank balance
04 - player bet
05 - winning number from spin of wheel
06 - player guess
07 - decimal seed

Instructions:

1) XEQ SPIN
2) Enter a 6 digit plus decimal seed at SEED? prompt between 0 and 1. Press R/S.
3) At BANK? prompt, enter amount of money held by the bank / house you are trying to win and press R/S.
4) At BET $? prompt, key how much you are betting per spin and press R/S. Valid entries are 0 through 37. The number 37 stands for the 00 place on the wheel.
5) Enter guess and press A to spin.
6) Display shows the number spun and how much you have won or lost in total. If you lose, the the amount of your bet is taken away from your winnings - if any! If you win, 35x the amount of your bet is added to your winnings. Of course, since there are 37 possible outcomes and you only get 35x added for a winning bet, the odds are in favor of the bank / house!
7) Go back to step 5.

Sample game:
XEQ SPIN
SEED? 0.123456789 R/S
BANK? 25000 R/S
BET $? 100 R/S
5 A and see #=3 $-100 --- so the number was 3 and I've lost $100. Easy come, easy go.
6 A and see #=6 $3400 so the number was 6 and I now have $3400. (35x$100 = $3500 less the previous $100 loss). Woohoo!
20 A and see #=32 $3300, so I have lost again.
and so on.

Enhancements I would like to see: I'd like to see the numbers 00 through 37 rapidly flicker through the display while the spin is occurring to mimic the wheel.

Note: The # character on line 18 was entered synthetically. If you don't want to use it use "Num=" or something else. :-)

Code:
             01◆LBL "SPIN"
             02 FIX 0
             03 CF 29
             04 CLX
             05 STO 02
             06 "SEED?"
             07 PROMPT
             08 STO 07
             09 "BANK?"
             10 PROMPT
             11 STO 03
             12 "BET $?"
             13 PROMPT
             14 STO 04
             15 CLX
             16 GTO 07

             17◆LBL 06
             18 "#="
             19 ARCL X
             20 "⊢ $"
             21 ARCL 02
             22 AVIEW

             23◆LBL 07
             24 STOP

             25◆LBL A
             26 X<0?
             27 GTO 04
             28 STO 06
             29 XEQ 00
             30 38
             31 *
             32 INT
             33 STO 05
             34 RCL 06
             35 X=Y?
             36 GTO 01
             37 RCL 04
             38 ST- 02
             39 ST+ 03
             40 GTO 02

             41◆LBL 01
             42 RCL 04
             43 35
             44 *
             45 ST+ 02
             46 ST- 03

             47◆LBL 02
             48 RCL 03
             49 X<0?
             50 GTO 05
             51 RCL 02
             52 RCL 05
             53 GTO 06

             54◆LBL 04
             55 ABS
             56 STO 04
             57 GTO 06

             58◆LBL 05
         59 "BANK BUSTS"
             60 PROMPT
             61 RTN

             62◆LBL 00
             63 RCL 07
             64 997
             65 *
             66 FRC
             67 STO 07
             68 END