The Museum of HP Calculators


Poker for the HP-41C

This program is Copyright © 2002 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

 1°) Playing against your HP-41
 2°) Playing with your HP-41    ( new )
 

-To simplify the programs, we use a deck of an infinite number of one-suit cards.
-In other words, the probability of each card is 1/13,
  and therefore, the order of the combinations is modified like this:
 
 
     combinations       probability  ranking
       high card           41%      0
         1 pair           46%      1
         2 pairs            7%      2
     3 of a kind           4.6%      3
       full house           0.4%      4
         straight*           0.3%      5
      4 of a kind           0.2%      6
      5 of a kind         0.004%      7

*Here, a straight is always a straight-flush!
  The lowest one is 2345A and the highest one is TJQKA
 

1°) Playing against your HP-41
 

-The HP-41 is always the dealer.

 0- A bet of 1000$ is placed automatically ( line 38 )
 1- The calculator deals 5 cards one by one to the player and to itself,
      the player's cards are gradually shown and the HP-41's cards are displayed as starbursts,
      then the cards are sorted out in increasing order, displayed again, and the program stops.
 2- At this step, key in a stake ( of about 1000$ or 2000$ for instance ) and press  R/S
    ( if the player simply presses R/S the HP-41 wins )
 3- Then, the HP-41 can  a)  fold ( the player wins and the new bank of the player is displayed )
                                       b)  match the player's bet.
                                       c)  make a higher bid ( which is displayed as "  + .... $" )
           In this case, the player can, in his turn:    a) fold  (  press     0   R/S  )
                                                                        b) match the HP-41's bet   (  press  ENTER  R/S )
                                                                        c) make a higher bid  ( key in a number greater than the HP-41's bid and R/S )  ... etc ...
 4- At the end of the stakes, the player's cards are displayed again and the program stops.
            -To exchange the cards number 1, 2, 5 ( if your hand is 45QQA for example )  press  125   R/S
            -If you have a complete hand, simply press  R/S
 5-The HP-41 displays the remaining cards of the player and as many starbursts as its own remaining cards.
 6-About 12 seconds later, the new hand of the player is displayed ( followed by / and 5 starbursts ) and the program stops.
 7-The second round of betting takes place here just like in steps 2 and 3
   ( To fold immediately, simply press R/S ).
 8-If the final bet or raise is not called, the new bank of the player is displayed, but the calculator's cards remain unknown.
    Otherwise, the HP-41 displayed its own cards one by one and then it displays the new bank of the player.
 9-Press R/S to continue the game.
 

Remarks:

  1-If the player exchanges 3; 2; 1; 0 cards, the HP-41 will fold unless it has ( at least )
     one pair; three of a kind; two pairs; a full house ( respectively ).     ( lines 183 to 191 )
  2-This strategy is very simple, so don't play too aggressively against your HP-41 ...
      ( but remember that the HP-41 can bluff in the second round of betting ( lines 177 to 182 ) ).
  3-Don't disturb rashly the stack during the raises.
  4-Digit entry lines are very slow. Therefore, execution time can be saved by storing these numbers in data registers:
       for instance replace line 211 by RCL 41 and key in 1.015008 STO 41 just after line 27 ... etc ...

Data Registers:

  R00 thru R40 are used.  R00 and R12 must be initialized before executing "POKER"

    R00 = random numbers
    R12 = the bank of the player ( the cash )

  R01 thru R05 are the HP-41's cards  R06 thru R11 are used for temporary data storage
  R15 thru R19 are the player's cards   R20 thru R22 ------------------------------------
  R10 is also used for the HP-41's raises.
  R08 and R22 are also used to store the values of both hands.
  R21 is also used to store the player's hand.
  R23 = /¤¤¤¤¤   ( ¤ symbolizes
  R24 = /¤¤¤¤      the starburst,
  R25 = /¤¤¤         the hidden cards
  R26 = /¤¤           of the HP-41 )
  R27 = /¤
  R28 = the "2s"
  R29 = the "3s"
  ....................
  R39 = the "Ks"
  R40 = the "As"

Flags:   F06

Subroutines:  none.
 

Analysis of the program:

-Lines 02 to 27 initialize the registers containing the cards ( 2 , 3 , ... , 9 , T , J , Q , K , A )
      and the hidden cards of the calculator ( displayed as starbursts )
      They are executed only once.
-Lines 28 to 59 place the initial bet ( 1000$  line 38 ) and deal the cards one by one
-Line 60 ( XEQ 09 ) sorts the cards, calculates the value of the HP-41's hand and stores in R10
      the maximum amount of money that the HP-41 will accept.
-Lines 61 to 68 modify this sum when the calculator has 4 cards in sequence ( like 6789K ) which can lead to a straight.
      In such a case, the HP-41 will raise the bets just as if it had two pairs.
-Lines 70 to 94 concern the bettings:
       if the player keys in 0 R/S ( or simply R/S at the first time ) the HP-41 wins the pot.
       -------------------  ENTER^  R/S  the raises are called.
       -------------------  a bet and R/S there are 3 possibilities:
               If the total amount of the raises is higher than the number in R10 the player wins the pot.
               ------------------------------- is smaller than R10 but greater than 0.4*R10, the HP-41 is in.
               ------------------------------- is smaller than 0.4*R10, the HP-41 makes a higher raise ... etc ...
                    This raise is choosen randomly but the total amount of the previous bets is also taken into account )
-Lines 104 to 112 are the showdown: the calculator displays its cards one by one.
-Lines 113 to 137 display the player's bank.
-Line  138 returns to line 28
-Lines 139 to 175 display the remaining cards of the player ( and as many starbursts as the remaining cards of the HP-41 ) after discarding.
-Line  176 executes the LBL 09 ( see below )
-Lines 177 to 182 are the calculator's bluff ( only in the second round of betting ):
       The number in R10 is divided by a random real number r ( 0 < r < 1 ).
-Lines 183 to 191 are the HP-41's strategy ( as explained in the 1st remark above )
-Lines 192 to 193 return to line 70 ( the betting )
-Lines 194 to 209 calculate and store in R10 the maximum amount of money that the HP-41 will accept.
      This number suits to bets of  a few thousand ( or ten thousand ) dollars.
-Lines 210 to 222 replace the discarded cards by new ones.
-Lines 223 to 263 sort out the cards in increasing order ( in R01 to R05 )
-Lines 269 to 288 calculate the value of the hand in R08
      The result is also used to obtain the number in R10 which is proportional to the square of R08.
      The number 37 ( line 271 ) can be changed but must not be too small ( not smaller than 16 ).
      Otherwise, the order of the different hands could become wrong.
-Lines 289 to 300 deal the cards. The random number generator used by this LBL 08
      is quite simple:   R-D  FRC
      It's perhaps not a perfect one but it's good enough for a game.
-Lines 301 to 454 concern the evaluation of the hand, the cards to be exchaned ...etc...
      The details are somewhat complex, but it works well!

  For instance, if the HP-41's hand is  3377K we have: R01 = R02 = 29 (the "3s") ; R03 = R04 = 33 (the"7s") ; R05 = 39 (the "K").
     R06 = 5 because the HP-41 will exchange its 5th card ( the King ) after the first round of betting.
     R07 = 2 = the ranking of the hand: two pairs.
     R08 = 33 ; R09 = 29 ; R10 = 39 ; R11 = 29
  Then, the value of the hand is obtained by   375*R07+374*R08+373*R09+372*R10+37*R11+R01 = 202058657 and stored in R08 ( line 287 ).
   ( In this example, R11 and R01 could be replaced by zero in the above formula, but it's not necessary ).
  This number characterizes the hand and allows to compare the HP-41's hand with the player's hand.
   (R08/E6)2 = 40827.7 $ is then stored in register R10 ( line 210 ).
 
 
 

Program Listing:
 

- In this listing, the "append" character is replaced by "~"
- The functions XTOA  ATOX  REGSWAP of the X-Functions module are used.
- CLRGX is also used, but if you don't have an HP-41 CX, replace lines 154 to 157 by

     X<=0?
     GTO 07
     0
     STO IND Y
     RDN
     GTO 03
     LBL 07
 

  01  LBL "POKER"
  02  27
  03  "A"
  04  ASTO 40
  05  35
  06  "K"
  07  ASTO 39
  08  1
  09  "Q"
  10  ASTO 38
  11  9
  12  "J"
  13  ASTO 37
  14  "T"
  15  ASTO 36
  16  "/"
  17  LBL 01
  18  STO IND Z
  19  R^
  20  XTOA
  21  ASTO IND X
  22  RDN
  23  DSE T
  24  DSE Z
  25  DSE X
  26  X>Y?
  27  GTO 01
  28  LBL 12
  29  CLX
  30  STO 20
  31  CF 29
  32  FIX 0
  33  SF 06
  34  5
  35  STO 06
  36  19
  37  STO 07
  38   E3
  39  STO 14
  40  27
  41  CHS
  42  STO 13
  43  CLA
  44  ASTO 21
  45  LBL 02
  46  CLA
  47  ARCL 21
  48  RCL 07
  49  XEQ 08
  50  ARCL IND X
  51  ASTO 21
  52  RCL 06
  53  XEQ 08
  54  ARCL IND 13
  55  AVIEW
  56  ISG 13
  57  DSE 07
  58  DSE 06
  59  GTO 02
  60  XEQ 09
  61  RCL 07
  62  X#0?
  63  9
  64  RCL 06
  65  +
  66  7
  67  X>Y?
  68  ST* 10
  69  CLST
  70  LBL 14
  71  PROMPT
  72  X=0?
  73  GTO 07
  74  ST+ 14
  75  X=Y?
  76  GTO 10
  77  RCL 14
  78  RCL 10
  79  X<Y?
  80  GTO 06
  81  .4
  82  *
  83  X<=Y?
  84  GTO 10
  85  *
  86  SQRT
  87  RCL 00
  88  R-D
  89  FRC
  90  STO 00
  91  *
  92  " +"
  93  ARCL X
  94  GTO 14
  95  LBL 10
  96  CLA
  97  ARCL 21
  98  RCL 13
  99  X<0?
100  GTO 10
101  5
102  "~/"                     ( I mean  2 characters:  append and / )
103  1
104  LBL 04
105  RCL IND X
106  ARCL IND X
107  COS
108  AVIEW
109  SIGN
110  +
111  X<=Y?
112  GTO 04
113  RCL 22
114  LBL 07
115  RCL 08
116  -
117  GTO 07
118  LBL 06
119  RDN
120  -
121  -
122  STO 14
123  LBL 07
124  X#0?
125  SIGN
126  RCL 14
127  *
128  ST+ 12
129  RCL 12          ( lines 129-131-132 are not necessary and can be deleted )       Each one will modify lines 129 to 134
130  " C="              ( 3 characters:  space C = )                                                        to display the cash according to his
131  X>0?                                                                                                               preference.
132  "~+"                ( 2 characters:  append and + )
133  ARCL 12
134  "~ $"               ( 3 characters:  append space $ )
135  FIX 4
136  SF 29
137  PROMPT
138  GTO 12          ( a synthetic three byte GTO )
139  LBL 10
140  ARCL 23
141  CLX
142  PROMPT
143  STO 20
144  CLA
145  X#0?
146  ARCL X
147  ALENG
148  ST+ X
149  STO 13
150  LBL 03
151  ATOX
152  34
153  -
154  X>0?
155  CLRGX
156  X>0?
157  GTO 03
158  3
159  E^X-1
160  15
161  LBL 13
162  RCL IND X
163  X#0?
164  ARCL IND X
165  SIGN
166  +
167  X<=Y?
168  GTO 13
169  RCL 06
170  DSE X
171  LOG
172  24
173  +
174  ARCL IND X
175  AVIEW
176  XEQ 09
177  SIGN
178  RCL 00
179  X^2
180  -
181  SQRT
182  ST/ 10
183  PI
184  PI
185  RCL 13
186  -
187  X<0?
188  +
189  RCL 07
190  X<=Y?
191  STO 10
192  CLST
193  GTO 14            ( a three-byte GTO )
194  LBL 09
195  XEQ 10
196  XEQ 10
197  CLA
198  ARCL IND 15
199  ARCL IND 16
200  ARCL IND 17
201  ARCL IND 18
202  ARCL IND 19
203  ASTO 21
204  ARCL 23
205   E6
206  /
207  X^2
208  STO 10
209  RTN
210  LBL 10
211  1.015008
212  REGSWAP
213  LBL 05
214  RCL 06
215  INT
216  10
217  ST/ 06
218  MOD
219  X#0?
220  XEQ 08
221  X#0?
222  GTO 05
223  STO 06
224  RCL 05
225  RCL 04
226  X>Y?
227  X<>Y
228  RCL 03
229  X>Y?
230  X<>Y
231  RCL 02
232  X<Y?
233  X<>Y
234  X<> 01
235  X>Y?
236  X<>Y
237  X<> 01
238  X>Y?
239  X<>Y
240  R^
241  X>Y?
242  X<>Y
243  RDN
244  X>Y?
245  X<>Y
246  RDN
247  X<Y?
248  X<>Y
249  STO 05
250  STO 08
251  RDN
252  X>Y?
253  X<>Y
254  STO 02
255  STO 11
256  RDN
257  X>Y?
258  X<>Y
259  STO 03
260  STO 10
261  X<>Y
262  STO 04
263  STO 09
264  FS?C 06
265  RTN
266  4
267  STO 07
268  XEQ 10
269  RCL 08
270  RCL 07
271  37
272  STO T
273  *
274  +
275  *
276  RCL 09
277  +
278  *
279  RCL 10
280  +
281  *
282  RCL 11
283  +
284  *
285  RCL 01
286  +
287  STO 08
288  RTN
289  LBL 08
290  RCL 00
291  R-D
292  FRC
293  STO 00
294  13
295  *
296  28
297  +
298  INT
299  STO IND Y
300  RTN
301  LBL 10
302  RCL 01
303  RCL 02
304  X=Y?
305  GTO 08
306  RCL 03
307  X=Y?
308  GTO 06
309  RCL 04
310  X=Y?
311  GTO 07
312  RCL 05
313  X=Y?
314  GTO 11
315  RCL 01
316  -
317  5
318  STO 07
319  X>Y?
320  RTN
321  RCL 04
322  LAST X
323  -
324  PI
325  X<Y?
326  GTO 09
327  R^
328  7
329  -
330  RCL 07
331  X#Y?
332  GTO 10
333  RCL 01
334  STO 08
335  RTN
336  LBL 09
337  RCL 05
338  RCL 02
339  -
340  X>Y?
341  1234
342  X<Y?
343  SIGN
344  LBL 10
345  STO 06
346  CLX
347  STO 07
348  RTN
349  LBL 11
350  123
351  GTO 09
352  LBL 06
353  RCL 04
354  X=Y?
355  GTO 10
356  RCL 05
357  X=Y?
358  SIGN
359  X<Y?
360  GTO 11
361  STO 09
362  RDN
363  STO 10
364  145
365  GTO 09
366  LBL 07
367  RCL 05
368  X=Y?
369  12
370  X<Y?
371  GTO 07
372  STO 09
373  125
374  GTO 09
375  LBL 08
376  RCL 03
377  X=Y?
378  GTO 06
379  RCL 04
380  X=Y?
381  GTO 08
382  RCL 05
383  X=Y?
384  3
385  X<Y?
386  GTO 11
387  STO 09
388  RDN
389  STO 10
390  RDN
391  STO 11
392  345
393  LBL 09
394  STO 06
395  X<> Z
396  STO 08
397  SIGN
398  STO 07
399  RTN
400  LBL 10
401  STO 08
402  RCL 05
403  X=Y?
404  SIGN
405  X<Y?
406  GTO 09
407  STO 09
408  15
409  GTO 07
410  LBL 06
411  STO 08
412  RCL 04
413  X=Y?
414  GTO 10
415  RCL 05
416  STO 09
417  X=Y?
418  RTN
419  X<>Y
420  STO 10
421  45
422  LBL 07
423  STO 06
424  3
425  STO 07
426  RTN
427  LBL 08
428  STO 08
429  RCL 05
430  X=Y?
431  RTN
432  STO 10
433  5
434  LBL 11
435  STO 06
436  RCL 02
437  STO 09
438  2
439  STO 07
440  RTN
441  LBL 10
442  7
443  STO 07
444  CLX
445  RCL 05
446  X=Y?
447  RTN
448  STO 09
449  5
450  LBL 09
451  STO 06
452  6
453  STO 07
454  END

( 629 bytes / SIZE 041 )
 
 

An example of game:
 

N.B: The first execution of the program is very slow because the XEQs and GTOs are not yet compiled.

0-Registers R00 and R12 are to be initialized, for instance:

            9 STO 00  ( avoid a seed like PI which would be converted into an integer by the R-D function )
    40000 STO 12
 

                                                                                  THE DISPLAY:         COMMENTS:
 

1- XEQ "POKER"                                                            T/¤                          ( ¤ symbolizes the starburst )
                                                                                         T6/¤¤
                                                                                         T64/¤¤¤
                                                                                         T64T/¤¤¤¤
                                                                                         T64T4/¤¤¤¤¤
             the player has two pairs                                        446TT/¤¤¤¤¤           the cards are sorted.

2-The 1st round of betting:                2000  R/S                    +1460                    the HP-41 makes a higher bid
              a new raise                         4000  R/S                    +2557                    idem
                 we are in                  ENTER^   R/S                  446TT/¤¤¤¤¤

3-We exchange the "6" ( the 3rd card )    3 R/S                  44TT/¤¤¤¤               the HP-41 has 2 pairs or a sequence of 4 cards.
    and ( 10 seconds later )                                                  44TTK/¤¤¤¤¤

4-The second round of betting:         3000  R/S                    +22441                   a raise
      to match the HP-41's raise:  ENTER^  R/S                   44TTK/2
                                                                                          44TTK/22
                                                                                          44TTK/22K
                                                                                          44TTK/22KA
                                                                                          44TTK/22KAA        The HP-41 wins!

                and the cash is displayed:                                      C = +5002 $

----------------------------------------------------------------------------------------------------------------------------------

1'-Let's continue:                            R/S                                J/¤
                                                                                           J3/¤¤
                                                                                           J33/¤¤¤
                                                                                           J339/¤¤¤¤
                                                                                           J3395/¤¤¤¤¤
            the player has one pair                                             3359J/¤¤¤¤¤

2'-1st round of betting                2000    R/S                        3359J/¤¤¤¤¤             the HP-41 is in

3'-We exchange the last 3 cards:   345   R/S                        33/¤                           the HP-41 has only a high card.
     and, (13 seconds later ),   three of a kind:                        3335K/¤¤¤¤¤

4'-2nd round of betting                 3000  R/S                         +4783                      a raise
                                                    6000  R/S                       3335K/5                    the HP-41 matches the bet
                                                                                           3335K/57
                                                                                           3335K/579
                                                                                           3335K/579K
                                                                                           3335K/579KK         the player wins the pot.

                    and the cash is                                                  C = +17002 $

----------------------------------------------------------------------------------------------------------------------------------

1"-One more time:                              R/S                            K/¤
                                                                                            K6/¤¤
                                                                                            K65/¤¤¤
                                                                                            K656/¤¤¤¤
                                                                                            K6567/¤¤¤¤¤
            one pair:                                                                   5667K/¤¤¤¤¤

2"-1st round of betting                  2000  R/S                        5667K/¤¤¤¤¤           the HP-41 is in

3"-We exchange the 1st, 4th and 5th cards:
                                                     145   R/S                        66/¤                          theHP-41 has a high card
              ( 13 seconds later )                                                 668TA/¤¤¤¤¤

4"-2nd round of betting                2000   R/S                         +12131                    the HP-41 makes a higher bid!

             a) if we fold:                      0       R/S    the cash:       C = +12003 $
             b) if we want to see    ENTER^  R/S                       668TA/3
                                                                                            668TA/3J
                                                                                            668TA/3JJ
                                                                                            668TA/3JJJ
                                                                                            668TA/3JJJA            three of a kind ( it was not a bluff! )

                     and the cash:                                                      C = -128 $             the player is in debt ...
 
 
 

2°) Playing with your HP-41
 
 

-The program may be simplified if your HP-41 becomes a one-arm bandit:
-Your calculator deals 5 cards,
  then you discard from 0 to 5 cards
  the HP-41 replaces these cards and
  -If you have 5 of a kind , you win 21 times your bet  ( line 256 )
  ------------ 4 ------------------- 13 --------------  ( line 263 )
  ------------ a straight    ---------  8  --------------  ( line 175 )
  ------------ a full-house --------   5  --------------  ( line 158 )
  ------------ 3 of a kind  --------   3  --------------  ( line 244 )
  ------------ two pairs    --------   2  --------------  ( line 252 )

  ------------ 1 pair of Jacks ( or higher )  you win 1 time your bet      |    lines 198 & 228
  ------------ 1 pair of 7s to 1 pair of 10s  your cash is unchanged      |            and
  ------------ 1 pair of 2s to 1 pair of 6s   you lose 1 time your bet     |    lines 68 thru 79

  ------------ a high card you lose 5 times your bet  ( line 192 )
 

-All these values are quite arbitrary and may be modified as you like.
 

Data Registers:           •  R00 = random numbers                ( Registers R00 & R06 are to be initialized before executing "POKER1" )
                                      •  R06 = your cash

                                         R01 to R05 = your 5 cards   ;   R07 thru R21: temp
Flags: /
Subroutines: /
 

-2 CX-functions are used ( GETKEYX and CLRGX ) but if you don't have an HP-41CX, replace lines 36 thru 45 by

     STOP           10                    -                        /
     LBL 03         MOD              0                        GTO 03                    Press  123  R/S  if, for instance, you want to discard the cards n°1-2-3 ( from the left )
     ENTER^       ST- Y             STO IND Y       LBL 10                     Simply press R/S if you have already a complete hand
     X=0?            6                     X<> Z                CF 22
     GTO 10        X<>Y             10
 

  01  LBL "POKER1"
  02  "A"
  03  ASTO 21
  04  "K"
  05  ASTO 20
  06  "Q"
  07  ASTO 19
  08  "J"
  09  ASTO 18
  10  16
  11  "T"
  12  ASTO 17
  13  9
  14  LBL 01
  15  STO IND Y
  16  DSE Y
  17  DSE X
  18  GTO 01
  19  LBL 12
  20  FIX 0
  21  CF 29
  22  " "                         one space
  23  ASTO 08
  24  5
  25  LBL 02
  26  CLA
  27  ARCL 08
  28  ENTER^
  29  XEQ 14
  30  ARCL IND X
  31  ASTO 08
  32  X<>Y
  33  AVIEW
  34  DSE X
  35  GTO 02
  36  LBL 03
  37  54
  38  GETKEYX
  39  X=0?
  40  GTO 10
  41  LASTX
  42  -
  43  CLRGX
  44  GTO 03               SST  this line in RUN mode before the first execution to compile the GTO 03
  45  LBL 10
  46  " "                         one space
  47  5
  48  LBL 13
  49  RCL IND X
  50  X#0?
  51  ARCL IND X
  52  X<>Y
  53  DSE X
  54  GTO 13
  55  AVIEW
  56  5
  57  XEQ 05
  58  " "                         one space
  59  5
  60  LBL 04
  61  RCL IND X
  62  ARCL IND X
  63  COS
  64  AVIEW
  65  X<>Y
  66  DSE X
  67  GTO 04
  68  RCL 07
  69  X#0?
  70  GTO 09
  71  17
  72  RCL 08
  73  X>Y?
  74  ISG 07
  75  INT
  76  14
  77  X>Y?
  78  DSE 07
  79  LBL09
  80  RCL 00
  81  FRC
  82  4
  83  /
  84  8
  85  +
  86  E^X
  87  RCL 07
  88  *
  89  ST+ 06
  90  RCL 06
  91  "  "                         2 spaces
  92  X>0?
  93  "~+"                       append  +
  94  ARCL 06
  95  "~ $"                      append  space  $
  96  FIX 4
  97  SF 29
  98  AVIEW
  99  CLA
100  STOP
101  GTO 12                 a three-byte GTO
102  LBL 14
103  CLX
104  RCL 00
105  R-D
106  13
107  MOD
108  STO 00
109  9
110  +
111  INT
112  STO IND Y
113  RTN
114  LBL 05
115  RCL IND X
116  X=0?
117  XEQ 14
118  X<>Y
119  DSE X
120  GTO 05
121  RCL 01
122  RCL 02
123  X>Y?
124  X<>Y
125  RCL 03
126  X>Y?
127  X<>Y
128  RCL 04
129  X<Y?
130  X<>Y
131  X<> 05
132  X>Y?
133  X<>Y
134  X<> 05
135  X>Y?
136  X<>Y
137  R^
138  X>Y?
139  X<>Y
140  RDN
141  X>Y?
142  X<>Y
143  RDN
144  X<Y?
145  X<>Y
146  STO 01
147  STO 08
148  RDN
149  X>Y?
150  X<>Y
151  STO 04
152  RDN
153  X>Y?
154  X<>Y
155  STO 03
156  X<>Y
157  STO 02
158  5
159  STO 07
160  RCL 05
161  RCL 04
162  X=Y?
163  GTO 08
164  RCL 03
165  X=Y?
166  GTO 06
167  RCL 02
168  X=Y?
169  GTO 07
170  RCL 01
171  X=Y?
172  GTO 11
173  RCL 05
174  -
175  8
176  STO 07
177  CLX
178  5
179  X>Y?
180  RTN
181  RCL 02
182  LASTX
183  -
184  PI
185  X<Y?
186  GTO 10
187  R^
188  12
189  X=Y?
190  RTN
191  LBL 10
192  5
193  CHS
194  STO 07
195  RTN
196  LBL 11
197  STO 08
198  CLX
199  STO 07
200  RTN
201  LBL 06
202  RCL 02
203  X=Y?
204  GTO 10
205  RCL 01
206  X=Y?
207  GTO 11
208  GTO 09
209  LBL 07
210  RCL 01
211  X=Y?
212  GTO 07
213  GTO 09
214  LBL 08
215  RCL 03
216  X=Y?
217  GTO 06
218  RCL 02
219  X=Y?
220  GTO 08
221  RCL 01
222  X=Y?
223  GTO 11
224  RDN
225  LBL 09
226  X<> Z
227  STO 08
228  CLX
229  STO 07
230  RTN
231  LBL 10
232  RCL 01
233  X=Y?
234  GTO 09
235  GTO 07
236  LBL 06
237  RCL 02
238  X=Y?
239  GTO 10
240  RCL 01
241  X=Y?
242  RTN
243  LBL 07
244  3
245  STO 07
246  RTN
247  LBL 08
248  RCL 01
249  X=Y?
250  RTN
251  LBL 11
252  2
253  STO 07
254  RTN
255  LBL 10
256  21
257  STO 07
258  CLX
259  RCL 01
260  X=Y?
261  RTN
262  LBL 09
263  13
264  STO 07
265  END

( 366 bytes / SIZE 022 )
 

Example:     3  STO 00   CLX   STO 06

 XEQ "POKER1"        the HP-41 displays     " 4"
                                                                     " 4J"
                                                                     " 4J9"
                                                                     " 4J9J"
                                                                     " 4J9J4"            you have 2 pairs
-If you want to discard the "9"
 ( the 3rd card ) press   3  ENTER^               " 4JJ4"              the remaining cards

-The HP-41 replaces this card,
  sorts the 5 cards and displays                      " 4"
                                                                    " 44"
                                                                    " 445"
                                                                    " 445J"
                                                                    " 445JJ"             still 2 pairs

                  followed by                                "  +6509 $"        you have  6509$
----------------------------------------------------------------------------------------------
-                     R/S                                        " Q"
                                                                    " Q4"
                                                                    " Q4T"
                                                                    " Q4TA"
                                                                    " Q4TA5"           only a high card

-You press   1 2 3 5   ENTER^
  in order to keep the ace                             " A"

-A few seconds later:                                   " 2"
                                                                   " 23"
                                                                   " 23K"
                                                                   " 23KA"
                                                                   " 23KAA"           one pair

                  followed by                               "  +10108 $"
-----------------------------------------------------------------------------------------------
-                     R/S                                        " Q"
                                                                    " QQ"
                                                                    " QQ4"
                                                                    " QQ4K"
                                                                    " QQ4K7"           one pair

-Press   3  4  5   ENTER^
 to discard the last 3 cards                            " QQ"

-Then                                                           " 2"
                                                                    " 26"
                                                                    " 268"
                                                                    " 268Q"
                                                                    " 268QQ"            the same pair

                  followed by                                "  +13859 $"
-----------------------------------------------------------------------------------------------
-                     R/S                                        " T"
                                                                    " T2"
                                                                    " T26"
                                                                    " T26Q"
                                                                    " T26Q3"           only a high card

-If you want to keep the Queen
  press  1  2  3  5   ENTER^                         " Q"

-And                                                            " 6"
                                                                    " 66"
                                                                    " 667"
                                                                    " 667Q"
                                                                    " 667QA"           one small pair  ( not enough to win )

                  followed by                                "  +10747 $"       and so forth ...
 

Notes:

-Simply press ENTER^ if you do not want to discard any card ( if you have a complete hand! )
-You can press other keys ( instead of ENTER^ )
  provided it's neither a numeric key nor CHS nor the decimal point.

-In this program, the bets are randomly computed ( approximately between 3000$ and 3800$ - lines 80 to 86 )
  but if you want to place your own bets:

    -Replace lines 80 to 86 by  RCL 22
    -Replace line 19 ( LBL 12 ) by  X<> Z  LBL 12  FS?C 22  STO 22

    -Place your bet in X-register before XEQ "POKER1"  or  R/S
    -If you want to use the same bet, simply press R/S without any digit entry

-The cards are sorted out only after discarding,
-Otherwise, it would needlessly increase execution time.
 

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall