[Program] Mastermind Solver

Discussion in 'Guides' started by Radiance, Sep 9, 2018.

  1. Radiance

    Radiance The new guy

    Since I suck at Mastermind, and the solvers I found through google are too annoying to use, I thought "Why not make my own solver ?".

    So here it is.


    (damn it's ugly)

    How to use:


    First, order your marbles as shown in the previous image and number them from 1 to 7.

    This means that Green is 1, Yellow is 2, Pink is 3, Blue is 4, Purple is 5, Black is 6, White is 7.

    The first move will always be 1234567 (which means: green, yellow, pink, blue, purple, black, white), play it.


    After playing a move, enter the number of Red (Correct color in the correct place) followed by the number of White (Correct color in the wrong place) marbles you get.

    If you don't get any Red marbles, type 0 for Red. If you don't get any White marbles, type 0 for White.

    After playing that move, I got 1 Red, and 2 White. Now I go to the program and write 1 and 2 at the end.


    Now click Try:


    Now it suggests the next move to be 1112223 (Which means green, green, green, yellow, yellow, yellow, pink). Let's play it.


    I got 0 red, and 1 white, enter that in my program and click Try.


    The program tells me to try 2445545 (which means Yellow, blue , blue, purple, purple, blue, purple ).


    Now just follow the images.








    Download link:


    Source Code

    Jean, SirBearLag, Whaddap and 4 others like this.
  2. Kapaznik

    Kapaznik Active

    Thx bro
  3. Kiro13

    Kiro13 Getting involved

    This is legal? megusta
    pandabaeee and Aerys like this.
  4. SweetPayback

    SweetPayback Literally Jesus

    Looks cool, do you have an average amount of rounds this program takes on finishing ? :D
    Winks likes this.
  5. Radiance

    Radiance The new guy

    I made some tests comparing the simple naive method (try 1111111 first, etc.. basically taking the first possible solution) and the method I use. These are the results:

    Simple results:
    1 0
    2 0
    3 1
    4 2
    5 11
    6 72
    7 302
    8 320
    9 209
    10 68
    11 14
    12 1
    13 0
    14 0
    15 0
    16 0
    17 0
    18 0
    19 0
    Heuristic results:
    1 0
    2 0
    3 0
    4 11
    5 87
    6 333
    7 405
    8 145
    9 17
    10 2
    11 0
    12 0
    13 0
    14 0
    15 0
    16 0
    17 0
    18 0
    19 0
    Same or better: 939
    Same: 196
    Better: 743
    Worse: 61
    I created 1000 random games, and solved them once with the simple method, and once using my heuristic.

    The first number is the number of attempts, and the second number is the number of games out of 1000 that was solved in that number of attempts.

    For example: 7 405 means that 405 out of the 1000 games was solved in 7 rounds.

    Same or better: 939 means that in 939 games out of the 1000 games my algorithm solved the game in either the same number of rounds or less.

    Better: 743 means that in 743 out of 1000 games, my algorithm solved the game in less number of rounds.


    From the numbers you can tell that for the simple method, the expected number of rounds is 7.899, and for my method, the expected number is 6.645

    So on average my method solves the game in 1.254 less rounds.
    SweetPayback, Slazzy and Atticus Lee like this.
  6. Radiance

    Radiance The new guy

    I guess only a GM can answer that question, though I think it's legal because there are already similar tools on the internet, this one is just faster and custom made.
    badguy and Atticus Lee like this.
  7. Nils

    Nils Active

    Well thank you now every channel is full on this
    But really thanks haha
    Radiance, Winks and Kapaznik like this.
  8. Exodus

    Exodus Snarky Remarks Administrator Admin Developer Staff

    There is no reason why this should be against the rules as we cannot police this in any way.
    I'd say that the reason you shouldn't use it would be that it feels more rewarding when you solve it on your own as opposed to having a computer program do it for you.

    Do keep in mind that DMS is in no way responsible for anything that happens to anyones machines should anything in the program cause unforseen issues.
  9. sentinel

    sentinel Well-Known

    shoutout to @Radiance for being the hero we need but dont deserve. tested and works 100%. highest # of rounds i got was 8. Lowest # of rounds was 5.
    Radiance and Whaddap like this.
  10. SweetPayback

    SweetPayback Literally Jesus

    Did you code this yourself ? If so, impressive :P
  11. Radiance

    Radiance The new guy

    Thanks, yes I coded this myself, I have a BSc in computer engineering.
    Whaddap and Atticus Lee like this.
  12. Jean

    Jean Here to stay Donator

    ok thank you, now I will do this in my 50 mules that I have.
    Clone likes this.