Found this board game in a cabinet and decided to make a text based one. There is no media required and it is kinda boring to look at, but it is still pretty fun. Anyway, a rundown of the game is this:
The computer makes a randomly generated set of 4 numbers (no doubles) from using the numbers 1-5 (with higher difficulty settings it can go up 9).
You have 10 guesses to try to guess that combination. The computer will only tell you how many numbers you got that are correct (right number and place), but won't tell you which ones.
compressed code
start:
Print "Welcome to Master Mind" : Print "Press any key to begin" : wait key : input "<Enter difficulty level (1-5)>",colors
if colors<1 or colors>5 : print "don't be retarded" : cls : goto start : endif
colors=colors+4 : Print "Randomizing combination. Colors:"+str$(colors)
dim solution(4) : dim guess(4)
for i=1 to 4
random:
x=rnd(colors-1)+1 : for b=1 to 4 : if x=solution(b) : goto random : endif : next b : solution(i)=x
next i
print "Code generated. You have 10 guesses to guess the correct sequence"
do
reinput:
correct=0 : input guess : lines=lines+1 : ink 0,0 : box 480,0,520,480 : ink rgb(255,255,255),0 : tries=tries+1
for i=1 to 4 : guess(i)=val(mid$(str$(guess),i)) : if guess(i)>colors : print "Please enter a valid guess" : lines=lines+1 : goto reinput : endif : if guess(i)=solution(i) : correct=correct+1 : endif : next i
if correct=4 : correct=0 : goto win : else : text 40,64+16*lines,"<"+str$(correct)+" correct>" : endif
if tries=10 : tries=0 : goto lose : endif : loop
win:
print "CONGRADULATIONS! YOU WIN! Press [ANY KEY] to play again" : wait key : cls : goto start : return
lose:
x$=str$(solution(1))+str$(solution(2)) : x$=x$+str$(solution(3)) : x$=x$+str$(solution(4)) : print "Sorry, you lose. The number was "+x$+". Press any key to try again" : wait key : cls : goto start : return
uncompressed:
start:
lines=0
tries=0
Print "Welcome to Master Mind"
Print "Press any key to begin"
wait key
input "<Enter difficulty level (1-5)>",colors
if colors<1 or colors>5
print "don't be retarded"
cls
goto start
endif
colors=colors+4
Print "Randomizing combination. Colors:"+str$(colors)
dim solution(4)
dim guess(4)
for i=1 to 4
random:
x=rnd(colors-1)+1
for b=1 to 4
if x=solution(b)
goto random
endif
next b
solution(i)=x
next i
print "Code generated. You have 10 guesses to guess the correct sequence"
do
reinput:
correct=0
input guess
lines=lines+1
ink 0,0
box 480,0,520,480
ink rgb(255,255,255),0
tries=tries+1
for i=1 to 4
guess(i)=val(mid$(str$(guess),i))
if guess(i)>colors
print "Please enter a valid guess"
lines=lines+1
goto reinput
endif
if guess(i)=solution(i)
correct=correct+1
endif
next i
if correct=4
correct=0
goto win
else
text 40,64+16*lines,"<"+str$(correct)+" correct>"
endif
if tries=10
tries=0
goto lose
endif
loop
win:
print "CONGRADULATIONS! YOU WIN! Press [ANY KEY] to play again"
wait key
cls
goto start
return
lose:
x$=str$(solution(1))+str$(solution(2))
x$=x$+str$(solution(3))
x$=x$+str$(solution(4))
print "Sorry, you lose. The number was "+x$+". Press any key to try again"
wait key
cls
goto start
return
Ever notice how in Microsoft word, the word "microsoft" is auto corrected to be "Microsoft" but "macintosh" just gets the dumb red underline?