Post Reply 
(11C) Code guessing game
04-28-2018, 07:10 PM (This post was last modified: 04-28-2018 07:17 PM by Michael Zinn.)
Post: #9
RE: (11C) Code guessing game
(04-26-2018 10:10 PM)Rogier Wrote:  Michaelzinn, what do you mean by human readable form?

To me, it was very difficult to understand how the program works. Comments, especially for the labels, would help. I reverse engineered the code and commented it a bit (Ignore the parens I'm currently experimenting with some ideas to "compile" code from edn):

Code:

        (LBL "check guess X"
            (CF "0: counted match")
            (STO "2: guess part")
            (STO "5: guess")
            (RCL "1: solution")
            (ISG        ; count guess?
                (X=Y?)) ; NOP ?

            ; display I
            (X><I))
            (PSE)
            (X><I)
            (FIX 9) ; won display
            (X=Y?    ; won?
                RTN) ; won! show fix 9
            (FIX 1) ; did not win, fix 1

            (STO "3: solution part") ; copy s1 to s3

            (LBL "2: compare current guess digit to every solution digit" ; 016

                ; solution checked?
                (X=0? (GTO 0)) ; check next guess digit

                (RCL "2 guess part") ; guess done?
                (X=0? (GTO 4)) ; all done, display result

                ; last digit correct?
                -
                10
                /
                FRAC
                (X=0? (GSB "7: found match")) ; yes

                ; no, cut last digit from s3 and try again
                (STO "3; solution part" (INT (* .1 (RCL "3solutionp"))))
                (GTO "2: compare lgd to every sd"))

            (LBL "0: proceed to next guess digit" ; 036 - 
                ; cut last digit from guess2
                (STO "guess2" (INT (/ (RCL "guess2") 10)))

                (CF "counted match")
                (STO "solution3" (RCL "soluton1"))
                (GTO "2: compare..."))

            (LBL "7: found match"
                (F "counted match"?
                    (GTO 7)) ; don't count again

                ; count 1 "right somewhere"
                (STO + "4: score guess" 1) ;right somewhere
                (SF 0) ;counted
                (LBL 7
                    ; correct position?
                    (INT (LOG (RCL "3: solution part")))
                    (INT (LOG (RCL "2: guess part")))
                    (-)
                    (X!=0?
                        RTN)
                    ; count as perfect match
                    (STO + "4: score guess" .1))

                (RTN))

        (LBL "C: new game"
            (FIX 1)
            (CLR SUM) ; 2-7
            3
            (STO I)
            (LBL "1: roll solution"
                ; move digits to the left
                (STO * "7: turns/loopC" 10)
                ; add another random digit
                (STO + "7:t/lc" (INT (+ 1 (* 9 RAN))))
                (CLx)
                (DSE I
                    (GTO "1: roll solution"))))
        (LBL "4: display score guess"
            (RCL 4)   ; show score, initally 0
            (STO - 4) ; clear R4
            (RTN))
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) Code guessing game - Rogier - 04-25-2018, 06:18 PM
RE: (11C) Code guessing game - Dieter - 04-26-2018, 06:57 PM
RE: (11C) Code guessing game - Rogier - 04-26-2018, 10:10 PM
RE: (11C) Code guessing game - Dieter - 04-27-2018, 06:54 AM
RE: (11C) Code guessing game - Dieter - 04-27-2018, 12:52 PM
RE: (11C) Code guessing game - Michael Zinn - 04-28-2018 07:10 PM
RE: (11C) Code guessing game - Rogier - 04-28-2018, 12:24 PM
RE: (11C) Code guessing game - Dieter - 04-29-2018, 09:00 PM
RE: (11C) Code guessing game - pier4r - 04-28-2018, 07:23 PM
RE: (11C) Code guessing game - Rogier - 04-29-2018, 09:58 PM
RE: (11C) Code guessing game - Dieter - 04-30-2018, 08:11 AM
RE: (11C) Code guessing game - Rogier - 04-30-2018, 07:29 PM
RE: (11C) Code guessing game - SlideRule - 07-23-2018, 03:22 PM
RE: (11C) Code guessing game - Rogier - 05-02-2018, 06:49 PM



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