Hacker News new | ask | show | jobs
by _v7gu 3344 days ago
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
4 comments

I don't know the answer to your question, but I was curious to know if 22 attempts was anywhere near a bruteforce attack on a 4 point pattern.

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!

he has help feedback from game, normal Android won't tell you which combinations are partially correct, so you are comparing apples and oranges
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.
In this vein, finding where you get 0 dots can be very useful as well.
I think trying to exclude nodes is more efficient than trying to find the correct ones.

After you excluded all "bad" nodes, you need to find the order. finding the order with the help of "bad" nodes was also faster for me

I went from 56 to a lucky 5 tries.

This is the same method I used. As soon as you knew which 4 dots, it was a matter of simple brute force to deduce the actual order.

only 49 tries for me. lol

Yeah, as Spare_account said, 22 attempts is probably a pretty good result for a first try at the game. I needed 60 :).