mind:global a$(16),z$(1),c%,p%,i%,j%,x,b$(9),c$(9),g$(9),l%global ok,i$(9,1),j$(9,1),b%,w%
GAMEUDG: :REM set top level icon
REM Initialise variablesa$="Master Mind Game"b$="ABCDEFGHI"x=int(rnd*10)randomize x
REM Jump back to here to restartstart::l%=1GameTOP:(2) :REM top line, icon and clock, sets the cursor on line 2
REM Get game options number of positions and letters maximum 9at 3,2 :print a$ :KSTAT 3do :at 3,3:print "No Positions 4-9" :p%=get :until p%>%3 and p%<=%9do :at 3,4:print "No Letters 4-9" :c%=get :until c%>%3 and c%<=%9i%=0 :c$="" :p%=p%-48 :c%=c%-48do :x=int(rnd*c%)+1 :c$=c$+mid$(b$,x,1) :i%=i%+1 :until i%=p%
KSTAT 1 :REM Set the status of the keyboard to CAPs GameTOP:(2)print "From =";left$(b$,c%) :REM Possible available letters to try
REM Jump to here to retrytry::at 1,4 :print "Q=Quit O=Off (Pos=";p%;")" REM p% tells the user no positionsat 1,3 :print "Try ";l% : at 8,3 :print "="; :input g$
REM Check for Q=Quitif loc(g$,"Q")>0GameTOP:(2) :print "Answer "; :print c$ :AT 1,4 :PRINT "Quit:"pause 20 :goto quit:: :endif
REM check for switch Offif loc(g$,"O") :off :goto try:: :endif
REM check that length guess is less that number of positionsif len(g$)<>p% :goto try:: :endif
REM Compare the guess with the answeri%=0do :i%=i%+1i$(i%)=mid$(c$,i%,1)j$(i%)=mid$(g$,i%,1)until i%=p%i%=0 :ok=0do :i%=i%+1ok=loc(left$(b$,c%),j$(i%))until ok=0 or i%=p%if ok=0 :goto try:: :endifl%=l%+1i%=0 :b%=0do :i%=i%+1if i$(i%)=j$(i%) :i$(i%)="K" :j$(i%)="L" :b%=b%+1 :endifuntil i%=p%i%=0 :w%=0do :i%=i%+1 :j%=0if i$(i%)<>"K"do :j%=j%+1if j$(j%)<>"L"if i$(i%)=j$(j%) :w%=w%+1 :i$(i%)="K" :j$(j%)="L" :endifendifuntil j%=p%endifuntil i%=p%at 1,2 :print "+";b%;" -";w% :at 8,2 :print "=";g$;" "if b%=p% :goto done:: :endif
REM Jump back for another trygoto try::
REM Completed print good then check for Quitdone::at 1,4:print "Good "
REM Jump to here to check for quittingQuit::at 8,4 :print " Go Again Y/N";:z$=get$if z$="y" or z$="Y" :goto start:: :endif