The Mastermind Solver for Mastermind lovers

Off topicProgramming → The Mastermind Solver for Mastermind lovers

SHOWCASE

Hello, this is my first programming post on redstoner and I didnt get much professional lessons so the code might be a little bit messy. Anyway, what I am about to show is a Mastermind solver. To use the solver it is pretty simple:

  1. Enter the colors and length. (E.g 8 colors, 4 space for you to guess: [insert 8 chars here] 4)
  2. Now go back to the game, randomly place your choices and wait for the other player to tell you how many correct color and corret placement you got.
  3. Now, go back to the program, enter the result you got. (E.g. You entered 1423 and you got 2 digits that is in correct color and correct position and 1 digits that is only correct color but not correct position, You enter “1432 2 1”)
  4. It will print a list of possible answers, pick one and try again.
  5. Enter the result you got again just like in step 3
  6. Repeat step 4 and 5 until you win.

How it works: First, it generate a list of possible answers. The user enters a input and it checks which answer has the number of correct digits and correct position same as the user’s input. THe one that matches stay and the others are removed from the list. This process repeats until there are only 1 answer left.

Code (c#): [http://pastebin.com/uPqaHEaY]

Screenshot: [http://i.imgur.com/0XGEerK.png]