Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All:
My Mother recently had surgery and so I am home taking care of things during her recovery. One thing she has asked me to do is go get her a new "Word Search" book. The object is to find a list of words in a grid of letters. I thought this would be a great project to do for her in Perl on the computer so she wouldn't have to buy any more books again.

I see no reason to re-invent the wheel if someone knows a source where I can download one for free please let me know. If not, here are some of the ideas that I have:

  • Allow games to be saved/restored
  • Allow games to be timed
  • Allow words to be added to repository
  • Allow changing of font/color/size
  • Provide some functionality for creation/importation of theme puzzles such as "words that begin with the letter e" or "animals you might find in the ocean".
  • Ability to set a difficulty level: Some of the ideas I have hear is purposely misleading letter combinations and/or looking at the letter frequency distribution of the word list and using more of those letters as filler. Another idea that I am not sure would work is allowing words to "wrap" around the grid.
  • Now I have no idea how to implement any of these ideas from the Perl/Tk design to the code logic. Any of the following would be greatly appreciated:

  • Pointers to good resources
  • Code outline (pseudo/real) for any ideas listed
  • Ideas for new features
  • Offer for calloboration
  • General information
  • Cheers and thanks in advance - L~R

    Replies are listed 'Best First'.
    Re: Perl/Tk Word Search Help/Suggestions
    by Courage (Parson) on Aug 23, 2003 at 09:09 UTC
      I can suggest you a way to increase a probabliity of successfull searching for your application, or any other perl+Tk.

      I also have several application good working this way.

      Find such application among Tcl/Tk applications (there are surprisingly many GUI application that do many different things, look at http://resource.tcl.tk/resource/software/applications/)

      After that you do

      use Tcl::Tk qw(:perlTk); my $int = new Tcl::Tk; $int->Eval(<<'EOS'); #...you...paste...tcl/tk code here # or write it source /path/to/my/file EOS # here you can access Tcl/Tk widgets by using my $button = $int->widget(".ff.path.to.widget"); # and tie perl variable to Tcl variable and it is # configured to be displayed on GUI my $labtext; tie $labtext, 'Tcl::Var', $int, "labtext"; # for example $button->configure( -command=> sub { print "Hey, man, you just pressed the button\n"; $labtext = "indeed, that man pressed the button"; }); $int->MainLoop;
      Then you can add powerful functionality by adding Perl-coded logic to Tcl/Tk GUI

      Not that I want to obtrude that way, but this is a way I have some GUI Perl applications working with really few efforts spent, and continuing coding using Perl only.

      Courage, the Cowardly Dog

    Re: Perl/Tk Word Search Help/Suggestions
    by CombatSquirrel (Hermit) on Aug 22, 2003 at 22:17 UTC
      I cannot really say that I could even write a simple Hello World script in Perl/Tk, but you might want to use Tk::Canvas. As to how to detect clicked letters, have a look at perl/Tk. You could just use a plain text file as a data base; one line per word, tab delimited, second to last entry in a line being index words for the word.
      This might, or might not help you; good luck anyways.
      CombatSquirrel
    Re: Perl/Tk Word Search Help/Suggestions
    by CombatSquirrel (Hermit) on Aug 22, 2003 at 23:28 UTC
      When I thought about what features I would like in such a game, it occured to me that I simply wouldn't play it on the computer. In some respects I really fancy paper, and I just would not play such a game for more than five minutes on a computer, whereas I could spend hours solving puzzles with pen and paper.
      In your place, I would first off make sure that your mother would play that game on a computer.
      Just a thought, though.
        CombatSquirrel,
        I actually had thought of that. I personally prefer the dead tree version of a book over an e-book anyday. My Mother does play Scrabble and a few other word games on the computer. One thing I know would detract her from using it would be if the font was too small and that's why I made flexibility a requirement. Thanks for the consideration - if I do it and it turns out half way decent I would be posting it here.

        Cheers - L~R

    Re: Perl/Tk Word Search Help/Suggestions
    by graff (Chancellor) on Aug 22, 2003 at 23:03 UTC
      A google for "word search game" turns up a bunch of sites that offer this sort of diversion on the web -- nice to scan for ideas on how to structure an application, but I don't know if you'll find any source code or implementation details that way.

      I'm guessing the tricky part is figuring out how to assign the letters to the grid positions so that all the words on a given list are attested just once each. If you can get your head around an algorithm for that, the rest should be easy. The use of a basic canvas widget to draw the grid is attractive, because it would be easy to overlay any other kind of graphic to mark words in the grid when they're found.

    Re: Perl/Tk Word Search Help/Suggestions
    by Anonymous Monk on Aug 23, 2003 at 06:01 UTC
      In about the year 1979 (of the previous century) I entered a contest to win a 5 1/4 floppy drive for inventing the best algorithm for placing the most words from a given list of words into a grid of letters. My entry was written in assembler on a Motorola 6800 development system. As it turned out neither I nor anyone else came up with any better method than a guided exhaustive search, to the great dissapointment of the contest perpetrators. In never found out why they wanted this algorithm, but I suspect they were trying to efficiently create crossword puzzles. Or else it was the CIA trying to decode Communist radio signals.
    Re: Perl/Tk Word Search Help/Suggestions
    by thor (Priest) on Aug 23, 2003 at 16:26 UTC
      Not to rain on your parade, but some people prefer the dead tree version. They're not very expensive ($5 for 100, IIRC), and they can be taken anywhere. While this will probably be a good learning experience for you, make sure she would appreciate it. You don't want to present it to her and have her say "Oh...look...word finds on the computer. How...lovely."

      thor