Welcome,
Share Files

Mastermind Game for Mathstudio

This is a implementation of the famous mastermind game for mathstudio
You start the game with the function mstart which creates a random array of digits stored in the init variable

init=mstart(4,6);0
means you have to guess 4 different digits out of 6 digits (1,2,3,4,5,6)

;0 at the end hides the Output

alternatively you can call mstart with a third Parameter

init=mstart(4,6,1);0
means two or more same digits are allowed

You input your guesses by calling the function mtry until the solution is found

e.g
mtry([1,2,3,4],init) gives the output
0.3
means that 3 digits are right but no digit has the right Position

1.2 as output
means 3 digits are right and one has the right Position

If all digits are right and in the right Position the game is over

If you are not patient you can
see the solution by typing the content of the variable
init(3)

Enjoy the game!