Hacker News new | ask | show | jobs
by onekorg 3342 days ago
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.

2 comments

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.