in response to an article in The Perl Review...
I also got interested in Jotto a while back. A friend had showed me how to play and I wanted to show another friend, but I found it frustrating discussing strategies when I knew the word I wanted them to guess. So, I wrote a script to play against.
http://wickline.org/j/
Interface rather undocumented
sub get_jotts {
my($probe, $target) = @_;
my %letters;
for ( split('',$target) )
{ $letters{$_}++ };
my $jotts = 0;
for ( split('',$probe) )
{$jotts++ if $letters{$_}-- > 0};
return $jotts;
}
http://wickline.org/fivers.tar.gz
http://wickline.org/j/index.cgi?show=dict
select a number N between 1..5
Sort dictionary, first by rough order of word commonality
then by the Nth letter
This will ensure that guesses use more
common words before obscure ones, and
that guesses aren't always alphabetically
early... makes play a pinch more "real"
PROBE:
for each probe in dictionary
next PROBE if we've already guessed this probe
for each term in our history of guesses
next PROBE unless score given to term was
the same as it would get if probe were target
if we get here, probe fits all term's scores
so return probe as our next guess
if we get here, no probe worked
so we don't know the word (or user mis-scored us)
Re:Kevin: I was unable to email you
queue on 2003-01-06T13:26:34
In response to your mail, no the Jotto module isn't available anywhere, yet, but I'd be happy to send it to you if you'd like. Your scoring algorithm seems much cleaner than mine, but I'd be interested to see what the speed differences are.
The code in my Jotto.pm hasn't been touched in a while. I've been thinking about doing a complete rewrite of the Jotto stuff, now that I have a little bit more of a clue about what I'm doing.
KevinRe:Kevin: I was unable to email you
wickline on 2003-01-06T21:33:29
> happy to send it to you if you'd like
Count me interested:) You can email me at
m-to_kevin-re_jotto [ at ] wickline.org
I haven't gotten around to looking into that MX issue yet, so I'll have to reply back via use.perl.org until I do:)
> interested to see what the speed differences
I'll do a benchmark if I get a chance....and presumably if I've got a chance to contribute to the module, then I'll have a chance to do a benchmark.
> thinking about doing a complete rewrite of the Jotto stuff
I've had that on my todo list (regarding my CGI version) for a handful of years now. I forget who said it (Knuth?) but "always plan to throw the first one away" (or something like that).
Thanks:)
-matt