0

I currently implementing knuths mastermind algorithm But I want to create a mastermind program, where the length of the code goes up to 15. And the amount of different colors is also 15.

So I have a problem with the Seed S, mentioned in the algorithm above. When I want to create a Seed S with all possibilities the Seed would have 15^15 entries. This is 4,378938904×10¹⁷. That´s too much to handle.

Anyone got another idea how to implement knuth's algorithm with 15^15 possibilities?

1 Answers1

0

You don't need a seed at all. A seed is used for testing when you want to generate the same "random" sequence. This generates all the combos under the sun where 1-15 are the different colors.

    Random rnd=new Random();
    for (int i=1; i<=15; i++) {
        System.out.print((rnd.nextInt(14)+1)+" ");
    }

}
Nick Ziebert
  • 1,258
  • 1
  • 9
  • 17
  • And the sequence won't repeat until he got through all the possibilities? – ThristBugz Jan 23 '17 at 13:57
  • No, if you ran that code a ton of times, eventually there will be a repeat. I think I see what you're trying to do. You want to generate every single combo possible, test it, and eventually this will lead you to the correct combo. A seed isn't how you will achieve this. – Nick Ziebert Jan 24 '17 at 02:02