Pretty neat. Is there some kind of "strategy guide" for mastermind-like games? I feel that I'm operating at close-to-brute-force levels (I spent 22 attempts at a 4-lock) and I'd love to get better
If we assume that you don't know the number of points in use on a phone you're trying to unlock, the consensus seems to be there are in the region of 390,000 distinct patterns. One correspondent doubled that.
In the case where you know the pattern has 4 points, the number of valid permutations was calculated to be 1624. Your 22 attempt crack is well short of that figure so I think you are being harsh on yourself by implying you basically just got lucky. You're good at this!
I wrote a program and I'm getting sub 6 for every easy game.
Think of the board as a grid of numbers.
0 1 2
3 4 5
6 7 8
Then an L shaped pattern would be the string 0367.
The main idea is that you first build a list of every possible combination of legal moves. Then you take a random guess from that list and you will get back the number of white and black dots.
Now, since you know your random guess and the right answer produces X white dots and Y black dots, you can remove from the list of possible combinations every combination that has:
dots(myGuess, combinations[i]) != (X, Y)
you can keep taking random guesses from this list and filtering after each attempt until you get the right answer, I'm not sure of the math but I think worst case It'll be 6-7 moves to find the right answer.
Reminds me of a program I had to write earlier in school to implement an AI that would create hangman puzzles and then cheat on them by lying to the person playing, but in a way that they wouldn't contradict themselves and would have a valid word that matches what they've said so far.
This Quora thread contains some interesting breakdowns of the number of possible patterns that Android permits.
https://www.quora.com/Android-operating-system-How-many-comb...
If we assume that you don't know the number of points in use on a phone you're trying to unlock, the consensus seems to be there are in the region of 390,000 distinct patterns. One correspondent doubled that.
In the case where you know the pattern has 4 points, the number of valid permutations was calculated to be 1624. Your 22 attempt crack is well short of that figure so I think you are being harsh on yourself by implying you basically just got lucky. You're good at this!