Post Reply 
(11c) Slot machine
08-21-2022, 08:02 PM (This post was last modified: 08-30-2022 02:14 PM by Rogier.)
Post: #1
(11c) Slot machine
This program emulates a slot machine on an HP-11c calculator.

Use:
Lbl D starts a new game, gives you 10 points and generates a 3-digit code; LMR [each 1 ... 7].
Output looks like: LMR,xxxyyy (Where xxx = points, yyy = number of turns played)
Lbl E allows you to change L and/or M and/or R. Starting E costs 1 point. Achieving a number XXy or yXX gives you X points, Achieving a number XXX gives you 2*X points. Options:
1 > E: Change L
2 > E: Change M
3 > E: Change R
4 > E: Change L & M
5 > E: Change L & R
6 > E: Change M & R
8 > E: Change L, M & R
You can't input the same number 2 times in a row.

Registers Used:
R0: Points
R1: M
R2: Temporarily used by Lbl 5
R3: R
R4: L
R5: Number of turns
RI: Player choice

Labels used:
Lbl D: Start game
Lbl E: Change L and/or M and/or R
Lbl 0: Generate Ran.nr. [1, 2...7]
Lbl 1: Change L
Lbl 2: Change M
Lbl 3: Change R
Lbl 4: Change L & M
Lbl 5: Change L & R
Lbl 6: Change M & R
Lbl 7: Compute score, build display
Lbl 8: Change L, M & R
Lbl 9: Initialise new game, CF1, replace L, M & R

Flags used:
F0:
Set by Lbl 2 so Lbl 4 only changes M an then jumps to Lbl 7 (otherwise L would be changed as well).
Set by Lbl 6 so Lbl 8 only changes M & R
Set by Lbl 7 so negative player points are displayed correctly

F1:
Set by Lbl D so on first use, Lbl E will change L, M & R
Set by Lbl 3 so Lbl 8 only changes R
Set by Lbl 7 if points are scored (so Lbl E will change L, M & R on next use)

Notes:
This program basically was an excuse to use "Gto I", one of the few functions of my HP-11C I had never used before. I spent most time working out the way F0 and F1 control program flow. I think that that made it a more interesting program than a boring series of Gsb-commands. Besides, I used all numerical labels, so the "boring series" isn't that easy.

I used the formula Int(((6,8*Ran#^2)+1,2) to calculate L, M & R, so higher numbers are more scarce than lower numbers. Adapt Lbl 0 if you prefer something else.

Code:
001 Lbl D
002 Clr Σ
003 1
004 1
005 Sto 0
006 SF 1

007 Lbl E
008 CF 0
009 F1?
010 Gto 9
011 Rcl I
012 x=y?
013 Rtn
014 R↓
015 CF 1
016 Sto I
017 Gto I

018 Lbl 0
019 Ran. Nr.
020 x2
021 6
022 ,
023 8
024 *
025 1
026 ,
027 2
028 +
029 Int
030 Rtn

031 Lbl 3
032 SF 1

033 Lbl 6
034 SF 0
035 Gto 8

036 Lbl 2
037 SF 0
038 Gto 4

039 Lbl 5
040 Rcl 1
041 Sto 2

042 Lbl 9
043 CF 1
044 Lbl 8
045 Gsb 0
046 Sto 3
047 F1?
048 Gto 7
049 Lbl 4
050 Gsb 0
051 Sto 1
052 F0?
053 Gto 7

054 Lbl 1
055 Gsb 0
056 Sto 4
057 Rcl 2
058 X≠0?
059 Sto 1
060 Sto-2

061 Lbl 7
062 CF 1
063 1
064 Sto-0
065 Sto+5
066 Rcl Σ+
067 x=y?
068 Sto+0
069 x=y?
070 SF 1
071 Rcl 4
072 x=y?
073 Sto+0
074 x=y?
075 SF 1
076 CF 0
077 1
078 0 
079 *
080 +
081 1
082 0
083 *
084 +
085 Rcl 0
086 X‹0?
087 SF 0
088 Abs
089 EEX
090 3
091 /
092 +
093 Rcl 5
094 EEX
095 6
096 /
097 +
098 F0?
099 Chs
100 Rtn

HP 33E, HP 11C, HP 48 SX, HP 35S
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)