Commodore 64 Basic code miniature - Mastermind game in Basic

Pubblicato il: 06 febbraio 2022
sul canale di: Just for the Fun of It – Commodore Retro & BASIC
455
8

This weeks miniature is a real classic. Crack a four digit code. A Mastermind variant. You can enter your guess as numbers separated with a comma. For example if you think the code is 1234 then enter this as follows; 1,2,3,4.
After entering you answer the program will show a full dot (chr$(113)) for each correct answer i.e. number correct and on correct position. It will show a open dot (chr$(119)) if the number is part of the code on wrong position.

note: As it is not allowed to use the characters greater then and smaller then you need to replace the "[" and "]" character in the code below in order to make it work.

10 print chr$(147):diml,s(4),a(4),c(4):?"solve the secret number"
20 fori=1to4:s(i)=int(rnd(1)*9):a(i)=0:nexti
30 ?:input"enter code:"; a(1),a(2),a(3),a(4):for i=1 to 4:c$(i)="":for p=1to4
40 if s(i)=a(p) and i=p then c$(i)=chr$(113):l=l+1:p=4:goto 60
50 if s(i)=a(p) and i[]p then c$(i)=chr$(119)
60 next p, i:if l=4 then 90
70 ?"answer:";:for i=1to4:print a(i);:next:?
80 ?"check :";:for i=1to4:print c$(i);:next:?:l=0:goto 30
90 ?"you cracked it"

The program uses an array of four in which each position is filled with a randomized value 0 and 8.
You can add a cheat line to see the generated code or use it to debug the program
65 ?"secret:";:for i=1to4:print s(i);:next:?


In questa pagina del sito puoi guardare il video online Commodore 64 Basic code miniature - Mastermind game in Basic della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Just for the Fun of It – Commodore Retro & BASIC 06 febbraio 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 455 volte e gli è piaciuto 8 spettatori. Buona visione!