[comp.sys.handhelds] Yahtzee for HP[24]8

jurjen@cwi.nl (Jurjen NE Bos) (08/31/90)

-------------------------------------------------------------------------------
This is a translation of an article, published by STORC. STORC (Stichting Ter
Ondersteuning van RPL Calculators) is the Dutch support-group for the HP48SX,
HP28S and HP28C. STORC publishes a (dutch) magazine, called "STORC
Nieuwsbrief", 10 times a year.
 
	Our address:    STORC p.a. Christ van Willegen
	Dordognelaan 45
	5627 HB  Eindhoven
	The Netherlands
-------------------------------------------------------------------------------

As an extra service, here are equivalent programs for both the 28[SC] and 48SX.
Of course, the 48 program is a little bit more advanced :-).  The programs
simulates a set of dice for the game yahtzee.  This is very convenient if
you're traveling, because real dice in an airplane are a pain :-).  I
played hundreds of games using these programs, and found them good enough
to use as a serious alternative to real dice (That's because those calculators
have very high-quality random generator.  In fact it is better than I have
ever seen on a big computer.  Nice work, guys.)

Happy playing!

This is the HP28 version.  You operate it by typing the numbers on the
dice you want to fix, then press YTZ.  Example:
YTZ gives 5 random dice
345 YTZ gives a 3, 4, 5, and two random dice.
Note that cheating is very easy; you'd better watch the other party if he/she
is busy.

YTZ:
\<<
  IF DEPTH
  THEN {}
    WHILE OVER
    REPEAT OVER 10 MOD 1 \->LIST + SWAP 10 / IP SWAP
    END SWAP DROP
  ELSE {}
  END
  WHILE DUP SIZE 5 <
  REPEAT RAND 6 * IP 1 + 1 \->LIST SWAP +
  END
  DSP
\>>

DSP:
\<< \-> l
  \<< "" DUP DUP 1 l SIZE
    FOR k {{1 3 1}{2 1 4}{2 3 4}{5 1 5}{5 3 5}{5 5 5}}
      l k GET GET LIST\-> 1 SWAP
      START {"   ""o  "" o ""  o""o o"} 4 ROLL GET 124 CHR + 4 ROLL +
      NEXT
    NEXT 1 3
    FOR k 1 OVER SIZE 1 - SUB k DISP
    NEXT
  \>>
\>>


This is the HP48 version.  It is directly downloadable, of course.
To start, press ROLL1.  The program will start up, and show 5 dice.
Dice can be locked by pressing the corresponding menu button.  After
the third throw, the dice cannot be locked anymore, and you can start over.

%%HP: T(3)A(R)F(,);
DIR
  ROLL1
    \<< TEXT CLLCD PICT PURGE 6 10
      FOR f f CF
      NEXT 1 5
      FOR I PICT I 26 * # 10h - { # 19h } + I 64 + CHR 1 \->GROB REPL
      NEXT CSTL 'ROLL2' + roll
    \>>
  ROLL2
    \<< CSTL 'ROLL3' + roll
    \>>
  ROLL3
    \<< { { } { } { } { } { } ROLL1 } roll
    \>>
  roll
    \<< 6 10
      FOR f
        IF f FC?
        THEN PICT f 6 - # 1Ah * { # 0h } + FACES RAND 6 * 1 + IP GET REPL
        END
      NEXT MENU { # 0h # 0h } PVIEW 3 FREEZE
    \>>
  TOGGLE
    \<< DUP 6 - # 1Ah * # 0h # 1Fh
      IF 4 ROLL DUP FS?
      THEN CF SWAP
      ELSE SF
      END PICT 4 PICK 4 PICK 2 \->LIST PICT 6 PICK 5 ROLL 2 \->LIST
      4 PICK 4 PICK 8 ROLL # 17h + 8 ROLL # 17h + 2 \->LIST SUB REPL
      # 18h # 18h BLANK REPL 3 FREEZE
    \>>
  CST { }
  CSTL { { "A" \<< 6 TOGGLE \>> }
    { "B" \<< 7 TOGGLE \>> }
    { "C" \<< 8 TOGGLE \>> }
    { "D" \<< 9 TOGGLE \>> }
    { "E" \<< 10 TOGGLE \>> } }
  FACES
    \<< "{GROB 24 24 "
    "FFFFFF10000810000810000810000810000810000810000810000810C308102408102408" +
    "10240810240810C308100008100008100008100008100008100008100008100008FFFFFF" +
    " GROB 24 24 " +
    "FFFFFF100008970008580008580008580008580008970008100008100008100008100008" +
    "1000081000081000081000081000E910001A10001A10001A10001A1000E9100008FFFFFF" +
    " GROB 24 24 " +
    "FFFFFF10000897000858000858000858000858000897000810000810C308102408102408" +
    "10240810240810C3081000081000E910001A10001A10001A10001A1000E9100008FFFFFF" +
    " GROB 24 24 " +
    "FFFFFF1000089700E958001A58001A58001A58001A9700E9100008100008100008100008" +
    "1000081000081000081000089700E958001A58001A58001A58001A9700E9100008FFFFFF" +
    " GROB 24 24 " +
    "FFFFFF1000089700E958001A58001A58001A58001A9700E910000810C308102408102408" +
    "10240810240810C3081000089700E958001A58001A58001A58001A9700E9100008FFFFFF" +
    " GROB 24 24 " +
    "FFFFFF1000089700E958001A58001A58001A58001A9700E91000089700E958001A58001A" +
    "58001A58001A9700E91000089700E958001A58001A58001A58001A9700E9100008FFFFFF" +
    OBJ\-> DUP 'FACES' STO
    \>>
END
--
|                 | "Never imagine yourself not to be otherwise than what |
| Jurjen N.E. Bos | it might appear to others that what you were or might |
|                 | have been was not otherwise than what you had been    |
|  jurjen@cwi.nl  | would have appeared to them to be otherwise."         |