Master Mind

Purpose : QBasic TAFE Assessment

Programs : QBasic

Scripts: QBasic

ZIP file Contains: QBasic & Mastermind Game


Created as a TAFE Assessment, the project had the requirements to take a existing game from the course text and modify it to create something different. Since i already knew a fair bit of QBasic, I decided to go further and create something that was 100% entirely my own work.

The classic game “Master Mind” entails a 2 player VS’s match-up where player 1 sets a selection of coloured markers and player 2 tried to guess the colours and combination sequence within a set number of attempts.

This version uses key touches to assign the selection of colours for both the setting of the sequence and guesses.

The Code:

[cc lang=”vb”]
CLS
‘ **********************************************************
‘ * *
‘ * IAN BLOTT *
‘ * *
‘ * *
‘ * Last Revised 27/3/2005 *
‘ * *
‘ **********************************************************

PRINT “”
PRINT “”
PRINT ” MasterMind ”
PRINT “”
PRINT “”
PRINT ” By Ian Blott ”
PRINT “”
PRINT “”
PRINT ” Due date 7/4/2005 ”
PRINT “”
PRINT “”
PRINT “”
PRINT “************************************************************”
PRINT “”
PRINT “”
PRINT “The computer has selected a pattern that consists of up to”
PRINT “seven(7) Colours. You will need to remeber that the colours”
PRINT “can appear more than once”
PRINT “”
PRINT “You have up to ten (10) guesses to get the combination correct”
PRINT “”
PRINT “”
PRINT “”
PRINT “”
PRINT “”
PRINT “”
PRINT “Press any key to play”

DO
LOOP UNTIL INKEY$ <> “”

a = 1
DO WHILE a < 7 RANDOMIZE TIMER compick(a) = INT(RND * 7 + 1) a = a + 1 LOOP DIM win AS STRING win = "no" CLS PRINT "*******************************************************" PRINT "*******************************************************" PRINT "** MASTERMIND! **" PRINT "** **" PRINT "** BY... **" PRINT "** IAN BLOTT **" PRINT "** **" PRINT "** COLOUR/KEY TABLE **" PRINT "** "; : COLOR 7, 1: PRINT " "; : COLOR 7, 2: PRINT " "; : COLOR 7, 3: PRINT " "; : COLOR 7, 4: PRINT " "; : COLOR 7, 5: PRINT " "; : COLOR 7, 6: PRINT " "; : COLOR 7, 7: PRINT " "; : COLOR 7, 0: PRINT _ " **" PRINT "** "; : COLOR 7, 1: PRINT " 1 "; : COLOR 7, 2: PRINT " 2 "; : COLOR 7, 3: PRINT " 3 "; : COLOR 7, 4: PRINT " 4 "; : COLOR 7, 5: PRINT " 5 "; : COLOR 7, 6: PRINT " 6 "; : COLOR 0, 7: PRINT " 7 "; : COLOR 7, 0: PRINT _ " **" PRINT "** "; : COLOR 7, 1: PRINT " "; : COLOR 7, 2: PRINT " "; : COLOR 7, 3: PRINT " "; : COLOR 7, 4: PRINT " "; : COLOR 7, 5: PRINT " "; : COLOR 7, 6: PRINT " "; : COLOR 7, 7: PRINT " "; : COLOR 7, 0: PRINT _ " **" PRINT "** **" PRINT "*******************************************************" PRINT "*******************************************************" PRINT "" PRINT "" PRINT "" PRINT "Please use the corresponding numbers to represent your desired" PRINT "Colour guess" y = 1 DO UNTIL y = 11 x = 1 DO UNTIL x = 7 DO correct = 0 cmmnd$ = UCASE$(INKEY$) IF cmmnd$ = "1" THEN arrpick(y, x) = 1 ELSE IF cmmnd$ = "2" THEN arrpick(y, x) = 2 ELSE IF cmmnd$ = "3" THEN arrpick(y, x) = 3 ELSE IF cmmnd$ = "4" THEN arrpick(y, x) = 4 ELSE IF cmmnd$ = "5" THEN arrpick(y, x) = 5 ELSE IF cmmnd$ = "6" THEN arrpick(y, x) = 6 ELSE IF cmmnd$ = "7" THEN arrpick(y, x) = 7 END IF END IF END IF END IF END IF END IF END IF LOOP UNTIL y = 11 OR win = "yes" OR cmmnd$ = "1" OR cmmnd$ = "2" OR cmmnd$ = "3" OR cmmnd$ = "4" OR cmmnd$ = "5" OR cmmnd$ = "6" OR cmmnd$ = "7" CLS PRINT "*******************************************************" PRINT "*******************************************************" PRINT "** MASTERMIND! **" PRINT "** **" PRINT "** BY... **" PRINT "** IAN BLOTT **" PRINT "** **" PRINT "** COLOUR/KEY TABLE **" PRINT "** "; : COLOR 7, 1: PRINT " "; : COLOR 7, 2: PRINT " "; : COLOR 7, 3: PRINT " "; : COLOR 7, 4: PRINT " "; : COLOR 7, 5: PRINT " "; : COLOR 7, 6: PRINT " "; : COLOR 7, 7: PRINT " "; : _COLOR 7, 0: PRINT " **" PRINT "** "; : COLOR 7, 1: PRINT " 1 "; : COLOR 7, 2: PRINT " 2 "; : COLOR 7, 3: PRINT " 3 "; : COLOR 7, 4: PRINT " 4 "; : COLOR 7, 5: PRINT " 5 "; : COLOR 7, 6: PRINT " 6 "; : COLOR 0, 7: PRINT " 7 "; : _COLOR 7, 0: PRINT " **" PRINT "** "; : COLOR 7, 1: PRINT " "; : COLOR 7, 2: PRINT " "; : COLOR 7, 3: PRINT " "; : COLOR 7, 4: PRINT " "; : COLOR 7, 5: PRINT " "; : COLOR 7, 6: PRINT " "; : COLOR 7, 7: PRINT " "; : _COLOR 7, 0: PRINT " **" PRINT "** **" PRINT "*******************************************************" PRINT "*******************************************************" PRINT "" PRINT "" PRINT "" a = 1 DO UNTIL a = 11 b = 1 PRINT " "; DO UNTIL b = 7 IF arrpick(a, b) = 7 THEN COLOR 0, arrpick(a, b) ELSE COLOR 7, arrpick(a, b) END IF PRINT arrpick(a, b); b = b + 1 LOOP COLOR 7, 0 PRINT " "; b = 1 correct = 0 DO UNTIL b = 7 OR win = "yes" IF arrpick(a, b) = compick(b) THEN COLOR 7, arrpick(a, b) PRINT " "; COLOR 7, 0 correct = correct + 1 IF correct = 6 THEN win = "yes" END IF ELSE PRINT "0"; END IF b = b + 1 LOOP a = a + 1 COLOR 7, 0 PRINT "" LOOP x = x + 1 LOOP IF win = "yes" THEN y = 11 ELSE y = y + 1 END IF LOOP PRINT "" PRINT "" IF win = "yes" THEN PRINT " You Win!" ELSE PRINT " You loose" END IF x = 1 PRINT " "; DO UNTIL x = 7 PRINT compick(x); x = x + 1 LOOP PRINT "" PRINT "Press any key to exit" DO LOOP UNTIL INKEY$ <> “”

[/cc]