dkirkby/CodeNames

Improve logic for avoiding certain clues

Opened this issue · 2 comments

The current implementation of model.get_clue(...) is too simple and ad-hoc. Visible words are now divided into four groups:

  • words associated with the clue
  • all words for our team
  • words for the other team or neutral
  • assassin word(s)

A clue is only accepted if it is a better match for all the clue words than any of the words for the other team or neutral. It must also be better than the assassin word by some margin.

Possible improvements:

  • Add separate margins for neutral words, other team words, assassin word(s).
  • Determine margins automatically from the distribution of similarity values for the proposed clue over the whole vocabulary (instead of using a fixed ad-hoc value).

As an example of what goes wrong with zero margin for neutral / other-team words, the best < clue found for this board is now sandwiches 2:

<NIGHT       <<<<<<<<<<<< -saturn      >HAM         <<<<<<<<<<<< 
<SCUBA_DIVER <<<<<<<<<<<< >RABBIT      -turkey      >>>>>>>>>>>> 
>ICE_CREAM   >MICROSCOPE  >MEXICO      <<<<<<<<<<<< #KID         
<STREAM      -lap         -hole        -bottle      -antarctica  
>>>>>>>>>>>> <<<<<<<<<<<< >COMIC       <ICE         >BACK        

However, there are 3 obvious matches: HAM, TURKEY (neutral), ICE_CREAM. I guess the AI determined that TURKEY is less similar than ICE_CREAM, but they must be close. Adding a margin would presumably make this clue less favorable.

I just created a branch new_get_clue to work on this next. The changes will mostly be in model.py but the get_clue() API will likely change so that will also affect engine.py and evaluate.py.