(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))