hp41programs

Yams

Yams for the HP-41CX


Overview
 

-This program allows you to play "Yams" with - but not against - your HP-41CX.
-"Yams" is a kind of Yahtzee game:
-"Yams" = 5 of a kind.

-You roll 5 dice, then, if need be, you can roll again some of these dice - at most 2 times at each turn - and you try to get one of the 13 combinations below.
-Then, you choose one of these combinations, which cannot be chosen again in the next rounds.

-If - for instance - you get several times  2  2  2  2  2, it may be registered as yams, full, 4 of a kind, 3 of a kind ...
-After 13 turns, the HP-41 displays your score, and the object is to get the highest score.
 

  COMBINATION            SCORING

  3 of a kind                Sum of all dice  +  10 points
  4 of a kind                Sum of all dice  +  20 points
  Full-house                 Sum of all dice  +  30 points
  Straight                     Sum of all dice  +  40 points
  5 of a kind = yams    Sum of all dice  +  50 points
  "+" combination        Sum of all dice  S                       any combination            if you press "+"  with  4 3 6 5 1  ( S = 19 )
  "-" combination         Sum of all dice  S'                      provided  S > S'           and then "-" with  4 4 6 5 1 ( S' = 20 ), you will receive 19 pts but not 20 pts.

  The ones                  Sum of the ones
  The twos                  Sum of the twos
  The threes                Sum of the threes
  The fours                 Sum of the fours
  The fives                  Sum of the fives
  The sixes                 Sum of the sixes

  If the sum of these last 6 sums reaches 60 points or more, you get a bonus of 30 points.

-There are many variants and the following program may be modified according to your preferences.
 

Instructions for Use:
 

0-  Initialize a random seed in register R00

1-  XEQ "YAMS"  the HP-41 displays  the 5 dice followed by  + - BCFYS         All the flag indicators:  user  0 1 2 3 4  are set
    -If you want to throw again the dice - say n° 1 2 4 ( as seen from the left )  press  1  2  4  ENTER^
    -Then if you want to roll again the dice 1 4 , press  1  4  ENTER^
    -The screen is displayed twice, then choose a combination ( if you have a "yams" , press  Y )
    -The corresponding indicator ( flag indicator or a character in the alpha register ) will have disappeared on the next round.

2-  Continue to throw again the dice if need be until the 13 rounds are over. The Hp-41 will display your score, preceeded by "BONUS",
      if you've got at least 60 points with the ones, the twos, ........ , the sixes.

Warning:

-If you get a satisfying combination before the 3rd attempt - i-e after rolling the dice only 1 or 2 times -
  press R/S  ( the display will blink ) and only then, press the key corresponding to your combination.

-You have 41 seconds to decide which dice you want to throw, but only 10 seconds to decide which combination to choose.
 

Program Listing
 

-We need indicators to show what combinations are still available:

-For the ones, I've choosen flag F01 , for the twos, F02 , for the thres, F03 , for the fours F04.
-Unfortunately, the state of flags F05 & F06 doesn't appear in the display.
-So, I've used F00 for the fives and F27 ( which is the "user mode" flag ) for the sixes.

-The seven other combinations appear as  +  -  B  C  F  Y  S   for  "+"  "-"  "3 of a kind"  "4 of a kind"  "Full-house"  "Yams"  "Straight"  respectively.

-I've chosen  B  because  "3 of a kind" = Brelan in French and  C because   "4 of a kind" = Carré in French
-Other choices are clearly possible...
 

Data Registers:           •  R00 = random seed                                ( Register R00 is to be initialized before executing "YAMS" )

                                          R01 = dice n°1         R06 = Full                R11 = 3 of akind          R16 = the fours
                                          R02 = dice n°2         R07 = Straight          R12 = 4 of a kind         R17 = the fives
                                          R03 = dice n°3         R08 = +                   R13 =  the ones            R18 = the sixes
                                          R04 = dice n°4         R09 = -                    R14 = the twos            R19 = 13 , 12 , .......... , 1 , 0
                                          R05 = dice n°5         R10 = Yams             R15 = the threes          R20 =  3 , 2 , 1 , 0

Flags:                               F01 = the 1's             F04 = the 4's
                                          F02 = the 2's            F00 = the 5's
                                          F03 = the 3's            F27 = the 6's
Subroutines: /

-The append character is denoted  ~
-Lines 73-82-306 are three-byte GTO's
 
 

  01  LBL "YAMS"
  02  FIX 0
  03  CF 29
  04  SF 00
  05  SF 01
  06  SF 02
  07  SF 03
  08  SF 04
  09  SF 27
  10  6.018
  11  CLRGX
  12  13
  13  STO 19
  14  LBL 01
  15  CLX
  16  STO 01
  17  STO 02
  18  STO 03
  19  STO 04
  20  STO 05
  21  3
  22  STO 20
  23  LBL 02
  24  5
  25  LBL 03
  26  RCL IND X
  27  X#0?
  28  GTO 03
  29  CLX
  30  RCL 00
  31  R-D
  32  6
  33  MOD
  34  STO 00
  35  INT
  36  1
  37  +
  38  STO IND Y
  39  LBL 03
  40  X<>Y
  41  DSE X
  42  GTO 03
  43  CLA
  44  ARCL 01
  45  ARCL 02
  46  ARCL 03
  47  ARCL 04
  48  ARCL 05
  49  RCL 08
  50  X=0?
  51  "~+"
  52  RCL 09
  53  X=0?
  54  "~-"
  55  RCL 11
  56  X=0?
  57  "~B"
  58  RCL 12
  59  X=0?
  60  "~C"
  61  RCL 06
  62  X=0?
  63  "~F"
  64  RCL 10
  65  X=0?
  66  "~Y"
  67  RCL 07
  68  X=0?
  69  "~S"
  70  AVIEW
  71  DSE 20
  72  FS? 30
  73  GTO 10
  74  LBL 04
  75  41
  76  GETKEYX   
  77  X<> L
  78  X=Y?
  79  GTO 02
  80  X<> L
  81  X=0?
  82  GTO 10
  83  48
  84  -
  85  CLRGX
  86  GTO 04
  87  LBL 72
  88  1
  89  XEQ 06
  90  STO 13
  91  CF 01
  92  RTN
  93  LBL 73
  94  2
  95  XEQ 06
  96  STO 14
  97  CF 02
  98  RTN
  99  LBL 74
100  3
101  XEQ 06
102  STO 15
103  CF 03
104  RTN
105  LBL 62
106  4
107  XEQ 06
108  STO 16
109  CF 04
110  RTN
111  LBL 63
112  5
113  XEQ 06
114  STO 17
115  CF 00
116  RTN
117  LBL 64
118  6
119  XEQ 06
120  STO 18
121  CF 27
122  RTN
123  LBL 06
124  5
125  SIGN
126  CLX
127  X<>Y
128  LBL 07
129  RCL IND L   
130  X=Y?
131  ST+ Z
132  RDN
133  DSE L
134  GTO 07
135  X<>Y
136  RTN
137  LBL 21
138  CHS
139  STO 06
140  RCL 01
141  RCL 02
142  X#Y?
143  RTN
144  RCL 04
145  RCL 05
146  X#Y?
147  RTN
148  RCL 03
149  X=Y?
150  GTO 05
151  RCL 02
152  X#Y?
153  RTN
154  LBL 05
155  XEQ 08
156  30
157  +
158  STO 06
159  RTN
160  LBL 53
161  CHS
162  STO 07
163  RCL 01
164  RCL 02
165  X=Y?
166  RTN
167  RCL 03
168  X=Y?
169  RTN
170  RCL 04
171  X=Y?
172  RTN
173  RCL 05
174  X=Y?
175  RTN
176  RCL 01
177  -
178  4
179  X#Y?
180  RTN
181  XEQ 08        
182  40
183  +
184  STO 07
185  RTN
186  LBL 51
187  XEQ 08
188  STO 09
189  RCL 08
190  X#0?
191  X>Y?
192  RTN
193  CHS
194  STO 09
195  RTN
196  LBL 61
197  XEQ 08
198  STO 08
199  RCL 09
200  X<Y?
201  RTN
202  CHS
203  STO 08
204  RTN
205  LBL 71
206  XEQ 08
207  50
208  +
209  STO 10
210  RCL 05
211  RCL 01
212  X=Y?
213  RTN
214  CHS
215  STO 10
216  RTN
217  LBL 12
218  CHS
219  STO 11
220  RCL 01
221  RCL 03
222  X=Y?
223  GTO 12
224  RCL 05
225  X=Y?
226  GTO 12
227  RCL 02
228  RCL 04
229  X#Y?
230  RTN
231  LBL 12
232  XEQ 08
233  10
234  +
235  STO 11
236  RTN
237  LBL 13
238  CHS
239  STO 12         
240  RCL 01
241  RCL 04
242  X=Y?
243  GTO 13
244  RCL 02
245  RCL 05
246  X#Y?
247  RTN
248  LBL 13
249  XEQ 08
250  20
251  +
252  STO 12
253  RTN
254  LBL 08
255  RCL 01
256  RCL 02
257  +
258  RCL 03
259  +
260  RCL 04
261  +
262  RCL 05
263  +
264  RTN
265  LBL 10
266  RCL 04
267  RCL 05
268  X>Y?
269  X<>Y
270  RCL 03
271  X>Y?
272  X<>Y
273  RCL 02
274  X<Y?
275  X<>Y
276  X<> 01
277  X>Y?
278  X<>Y
279  X<> 01
280  X>Y?
281  X<>Y
282  R^
283  X>Y?
284  X<>Y
285  RDN
286  X>Y?
287  X<>Y
288  RDN
289  X<Y?
290  X<>Y
291  STO 05
292  RDN
293  X>Y?
294  X<>Y
295  STO 02
296  RDN
297  X>Y?
298  X<>Y
299  STO 03
300  X<>Y
301  STO 04
302  AVIEW
303  GETKEY
304  XEQ IND X  
305  DSE 19
306  GTO 01
307  6.012
308  RCL 13
309  RCL 14
310  +
311  RCL 15
312  +
313  RCL 16
314  +
315  RCL 17
316  +
317  RCL 18
318  +
319  60
320  -
321  X<0?
322  GTO 11
323  " BONUS"
324  AVIEW
325  30
326  +
327  LBL 11
328  RCL IND Y
329  X<0?
330  CLX
331  +
332  ISG Y
333  GTO 11
334  60
335  +
336  "  "
337  ARCL X
338  "~ PTS"
339  AVIEW
340  FIX 4
341  SF 29
342  END

 
        ( 501 bytes / SIZE 021 )
 
 

      STACK        INPUT      OUTPUT
           X             /      your score

 
Example:    With the random seed   41  in register R00

                             MOVES                                                                   HP-41  DISPLAYS

              41  STO 00   XEQ "YAMS"    >>>>                                         34264+-BCFYS         All the indicators:  user  0 1 2 3 4  are set

If you try to get a maximum number of 4
you roll again the dice n° 1 3 4                     1  3  4   ENTER^                  24144+-BCFYS
you roll again the dice n°  1 3                         1  3     ENTER^                  44644+-BCFYS         the display blinks
You have a "4 of a kind", so you press  C                     C                          35266+-BFYS           C has disappeared

If you seek for a straight                                 5       ENTER^                    35265+-BFYS
Same move                                                    5       ENTER^                    35261+-BFYS          the display blinks
There are not a lot of points so we can choose "-"         -                            45144+BFYS           "-"  has disappeared

Suppose you roll again the dice n° 2 & 3       2  3    ENTER^                     46644+BFYS
You have a full-house, press  R/S   F
( Since you've got the combination
  before the 3rd throw, you must press  R/S
  before the corresponding key )                      R/S      F                              65416+BYS            F is no longer displayed

You roll again the dice 2  3  4                      2  3  4   ENTER^                    65416+BYS
same move:                                                 2  3  4   ENTER^                    66566+BYS
You can choose a 3 of a kind                                      B                             66312+YS               B has disappeared

Rolling again the dice  3  4  5                       3  4  5   ENTER^                    66411+YS
Same move                                                 3  4  5   ENTER^                    66663+YS
We can choose the sixes                                              6                            35166+YS                F27 ( user )  is cleared

Choosing to roll the dice  1  2  3                  1  2  3   ENTER^                    16666+YS
You roll the 1st dice only                                 1       ENTER^                    66666+YS
A Yams:                                                                      Y                            36464+S                   Y has disappeared

If you keep the fours                                   1  2  4   ENTER^                     52424+S
Same move                                                 1  2  4   ENTER^                    64434+S
We can choose the 3 fours                                           4                             43553+S                   F04 is clear

If you keep the fives                                    1  2  5   ENTER^                     13555+S
Same strategy                                               1  2     ENTER^                     63555+S
You save the fives                                                        5                             24212+S                  F00 is clear now

The twos,                                                     2  4     ENTER^                      22252+S
same strategy                                                 4       ENTER^                      22262+S
we count the twos                                                        2                             61663+S                  F02 is cleared

If we keep the 6                                           2  5     ENTER^                     64662+S
again                                                            2  5     ENTER^                     65664+S
The sixes has already been choosen
above, but we still have the "+"                                     +                             62131S                    "+"  has been removed

Keeping the ones                                      1  2  4   ENTER^                       44131S
again                                                        1  2  4   ENTER^                       32161S
Only 2 ones, but no better choice                                 1                             43334S                     F01 is clear

You keep the threes                                   1  5     ENTER^                        23335S
Again                                                         1  5     ENTER^                        13336S
Choosing the threes                                                     3                              13432S                    F03 is clear

Seeking for a straight                                    4        ENTER^                       13452S
Only 2 throws, so R/S first                          R/S           S                              BONUS

And the final display                                                                                    414 PTS

>>>>  Simply press  R/S  to continue the game...
 

Notes:

-The maximum score is 492 points - highly improbable !

-In this example, all the combinations have been found.
-Of course, it will not be always the case, and you'll often have to choose a combination that is not satisfied ( for example "yams" ) which will give zero point.
-The HP-41 always checks if the combination corresponds to the selected one and places a negative number in the corresponding register in that case.
-But these negative numbers are not added at the end ( lines 329-330 )

-I've chosen the letter B for "three of a kind" and C for "four of a kind" ( "Brelan" and "Carré" in French ).
-But if you prefer other letters, replace them in lines 57 and 60, but change also the corresponding LBL's:

-For example, if you want to use the letter "H" instead of "B" , replace line 57 by "~H" but replace also line 217  LBL 12  by  LBL 23
  because the letter "H" is at the 2nd row 3rd column on the HP-41 keyboard.

Variants:

-This game has many different rules !
-For instance, the bonus may be 35 points but if the sum is at least 63.
-If you prefer this rule, replace lines 319 & 334 by 63 and line 325 by 35.

-According to other rules, the sum of the dice is not counted for the yams.
-In this case, delete lines 208 & 206. ( XEQ 08 calculates the sum of the dice faces ).

-Using F00 for the fives & F27 for the sixes is not perfect, but if you have a better idea...