[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Jotto puzzle: first five guesses



On 22 Jul 99, at 15:57, Ronald J Kimball wrote:

> On Thu, Jul 22, 1999 at 03:35:41PM -0400, Bernie Cosell wrote:
> > 
> > In each turn, the computer simply picks a word *AT*RANDOM* [!] that is 
> > still possible [that is, that is still consistent with all of the 
> > previous info].  First word is just picked entirely at random, and you go 
> > from there.  Trust me: you *cannot* beat this program, even with this 
> > simple a strategy [although not so trivial to implement: hence the 
> > programming problem]
> > 
> 
> Do you play with the rule that each word must contain five unique letters
> with no repeats?  If so, I think I have a fairly simple way to implement
> this.  If not, it would be harder, but still not too difficult, I think.

Nope...  we played that ANY word was OK.  Novices always thought that 
syzygy would be a clever secret word, but it turns out that it isn't..:o)

The code wasn't actually all that difficult.  The way I implemented it is 
that the program had a "current wordlist" [initialized to be the entire 
wordlist, of course].  Then when it gets back an answer, it'd sweep over 
the wordlist removing the entries that wouldn't match, resulting in a 
shorter word list, from which it would pick a word at random, 
iterating...  Only slightly tricky part was getting multiple letters to 
match right [you guess 'queue', if the secret word was 'queen' you get 4 
jots, but if it were 'quite' you get only 3].

Oh: and it took one more trick: You have to always remove the word you 
just asked --- that word [the one you just asked] will obviously 
be consistent with that result and all previous ones, but equally 
obviously it is not the secret word, so you have to remove THAT one 
brute-force.


It ran a bit slow for the second guess, but after that it ran like 
the wind [which, interestingly, is generally exactly the reverse of 
how it goes for a human player: the first guess or two is fairly easy 
and then you slow down as you try to sort out all the implications to 
home in on the word: "lessee, it doesn't have an 'o' and looks like 
it has two 'l's and ...", etc]

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:bernie@fantasyfarm.com     Pearisburg, VA
    -->  Too many people, too few sheep  <--          

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe