Post Reply 
Ok, please look over the HP 41 Yahtzee game here
01-26-2016, 08:59 PM (This post was last modified: 01-26-2016 08:59 PM by Guenter Schink.)
Post: #5
RE: Ok, please look over the HP 41 Yahtzee game here
(01-25-2016 01:28 PM)Gene Wrote:  Thanks Sylvain.

I'm particularly interested in:

The scoring routines - especially for cases that should fail. 11235 should not be a small straight - does it score as one? (Answer no, but there are lots of such cases)

and

Places where my routines are byte hungry. The Large Straight routine (LBL 11) for example - can it be done shorter? How?

FYI - Labels 01 through 13 score the corresponding row on the scorecard. LBL 07 is the 3 of a kind label.

Thanks all. Please play the game and help test it before it gets replaced in the FUNSTUFF rom.
Gene,
you haven't recognized my refined and very compact solution that I posted here three weeks after the conference. Based on that approach I offer a combined routine for the small and large straight, which is 39 lines long

Code:
LBL 10        Start for small straight
XEQ 35        do the evaluation for straight
30            possible score
7            to compare with hit-counter
GTO36        goto final evaluation for score
LBL 11        start for large straight
+            No idea what's that for GENE recheck
XEQ 35        do the evaluation for straight
40            possible score
6            to compare with hit-counter
LBL 36        final evaluation for score
RCL Z        get hit-counter
X>Y?        not enough hits? then..
RTN            .. fail
RCL Z        otherwise get score
STO 20        and store
RTN            finished with success
LBL 35        evaluate for straight
RCL 15        If die two is 2
RCL 17        and die four is 5
*            then there is a hole, and no small straight,
10            not relevant for large straight
X=Y?        but handy to have the 10 also available as hit-counter
RTN            .. failed
RCL 23        Get loop counter 14.018
ISG X        Add 1 for retrieval of next number
RCL 14        Get first number
ENTER^        create dumy number for later use
LBL 50        start loop
SIGN        turn previous dummy number into "1"
+            increase first number by one
RCL IND Y    get next number
X=Y?        if they are equal then we have a hit and
DSE T        decrease the hit-counter, it started with 10
X<>Y        save the last retrieved number to Y. X is dummy now
ISG Z        increase loop counter    
GTO 50        if something left to do
R^            lift stack to move hit-counter to X
RTN            go back to score evaluation

In your code you have "+" right after "LBL 11" . As I have no idea what that's for, I left it in, may be it can be deleted.

Hope you can use it,
Günter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Ok, please look over the HP 41 Yahtzee game here - Guenter Schink - 01-26-2016 08:59 PM
New version of Yahztee game - Gene - 01-26-2016, 09:33 PM



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