A guess the word game A guess the word game
The agreed dictionary.  All words are 6 letters long with all letters distinct
Rules:  This is a game of two players and the task will be to implement Player 2.
Player 1 chooses a word from the agreed dictionary
Player 2 repeatedly guesses a word from the agreed dictionary.
At each turn, Player 1 tells Player 2 how many letters the guess has in common with the secret word.  For example, youths and devout have three letters in common.
Goal
Player 2's goal is to guess the word in as few turns as possible.
Task
The task is to implement player 2 to minimize the maximum number of guesses they ever have to make. Your score is the maximum number of guesses made when considered over all the words in the agreed dictionary. A lower score is better.
You should test  your code by choosing each word from the agreed dictionary in turn and see how many guesses your implementation of Player 2 needs. You should then output the maximum.
Objective winning criteria
Answers will first be compared by the score they get using the rules above. Two answers with the same score will then be compared using code-golf rules. That is by the number of bytes in the code.
Ruby, 418 bytes, score 12 (on 'palest')



$dict = File.readlines('agreeddict.txt').map(&amp;:chomp)

def search(wrd)
  words = 0
  fdic = $dict.clone
  guess = ''
  starters = ['earths','blowup','coding']

  chs = wrd.chars

  while guess!=wrd do
    guess = starters.pop || fdic.pop
    words += 1
    ghs = guess.chars
    chars = (chs|ghs).size
    fdic.select!{|w|(w.chars|ghs).size == chars}
  end

  words
end

upp = 0;

p $dict.map{|w|
  [search(w),w]
}.max


Try it online!

Runs in 15 seconds on my machine.

TIO link for reference only - does not work if the file is not in the current directory.

The trick

Instead of brute-force elimination, try a list of initializers first. A lot of words differ by only 1 character and it's easy to get stuck in a single-letter elimination loop.

The most difficult words to guess are those with 4-5 very common characters (a e r s t), 1-2 'outsiders' (c p x z...) and some anagrams in the dictionary.

For example, when we reach a word containing the letters "a e r s t" and the answer is 5: if we just filter all the entries containing these 5 characters, we are left with a dictionary of 40 similar words, and then we have to try almost all of them, removing only a few words at each step.

We need to remove these words first, and we filter on the least common character, so if we get to "earths", and Player 1 answers 5, we don't have a lot of words to check. The first 2 words we always check are "coding" and "blowup" (no pun intended).

Now we can try with  a word containing the 5 most common letters ("earths"). If the answer is 4 or 5 (which is likely), we don't have a lot of words to choose from, because we already filtered all the words containing only 1 or 2 uncommon letters (and we only used 3 guesses to get here).

Finding the right initializers was a little tricky, I started with a list of 5 "quasi orthogonal" words (with as few letters as possible in common, a good start was "sporty fuzing hawked climax jumble", missing only the letter z) and got to 13, then started a test on automatically generated smaller lists.

'palest' seems to be a worst case, having 6 anagrams and 4 very common letters, but it's not the only word requiring 12 guesses, so I don't think I could get a better score with this approach.

I don't want to golf this.