Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: using perl to find words for scrabble

by pryrt (Abbot)
on Sep 07, 2019 at 18:08 UTC ( [id://11105799]=note: print w/replies, xml ) Need Help??


in reply to Re^2: using perl to find words for scrabble
in thread using perl to find words for scrabble

My invocation is perl -e "use Games::Literati qw(wordswithfriends); $Games::Literati::WordFile = qq(/usr/dict/wordswithfriends.dict) ; wordswithfriends()" < t.txt

Looking at your invocation: you're obviously on windows; the -e one-liner on Windows requires double-quotes, not linux single quotes; if I try with linux single quotes, I get nothing. If I convert your oneliner to double-quotes instead of single-quotes, it gives the error:

Hashing words... Cannot open words file "./wordlist" No such file or directory at -e line 1.

For your setup, I believe you should use perl -MGames::Literati=scrabble -e"$Games::Literati::WordFile = 'c:\users\tblaz\documents\html_template_data\dict\enable1.txt'; scrabble()" < t.txt. In your script version, $WordFile should not be a my variable; it's part of the Games::Literati module, so, as the documentation says, "These variables are exportable, so can be fully qualified as %Games::Literati::valid, or if included in the export list when you use the module, you can reference them directly", and then gives a multiline example. In your case you'll either need to use Games::Literati qw(scrabble $WordFile); $WordFile = '...';, or use the variable fully qualified variable name, as in use Games::Literati qw/scrabble/; $Games::Literati::WordFile = '...';

Replies are listed 'Best First'.
Re^4: using perl to find words for scrabble
by Aldebaran (Curate) on Sep 12, 2019 at 02:54 UTC

    I have output now, and I must say, it is impressive. Quick, too. There's probably much more time in keeping an accurate representation of the board than thinking time for a best next move:

    C:\Users\tblaz\Documents\evelyn>perl -MGames::Literati=scrabble -e"$Ga +mes::Literati::WordFile = 'c:\users\tblaz\documents\html_template_dat +a\dict\enable1.txt'; scrabble()" < t.txt Hashing words... ... ---------Scrabble---------- Board: ............... ............... ............... .......c....... ......ai....... .......s.header .......t....r.. ...jurors..soup .......o....p.h .upsilon.f..pea .......speering .........s..n.e .........t..g.. .........e..... ........broils. Is the above correct? wild tiles are at:[Row1,Col1 Row2,Col2 ...] Enter tiles: Looking for solutions for eurmsss(in X axis)... Board: ............... ............... ............... .......c....... ......ai....... .......s.header .......t....r.. ...jurors..soup .......o....p.h .upsilon.f..pea .......speering .........s..n.e .........t..g.. .........e..... ........broils. using 6 tiles: (18) row 3 become: 'cussers' starting at column 8 (9) row 12 become: 'russets' starting at column 4 using 5 tiles: (16) row 3 become: 'cruses' starting at column 8 (16) row 3 become: 'curses' starting at column 8 ... (2) column 14 become: 'er' starting at row 4 (7) column 14 become: 'phages' starting at row 12 Possible Top Ten Solution 1: row 14 become: 'embroils' starting at col +umn 6 using 2 tile(s), score 36 Possible Top Ten Solution 2: row 4 become: 'aimer' starting at column +8 using 3 tile(s), score 23 Possible Top Ten Solution 3: row 6 become: 'stems' starting at column +6 using 4 tile(s), score 23 Possible Top Ten Solution 4: row 6 become: 'stums' starting at column +6 using 4 tile(s), score 23 Possible Top Ten Solution 5: column 2 become: 'sperms' starting at row + 8 using 5 tile(s), score 22 Possible Top Ten Solution 6: column 2 become: 'spumes' starting at row + 8 using 5 tile(s), score 22 Possible Top Ten Solution 7: row 4 become: 'em' starting at column 9 +using 2 tile(s), score 21 Possible Top Ten Solution 8: row 4 become: 'um' starting at column 9 +using 2 tile(s), score 21 Possible Top Ten Solution 9: column 2 become: 'sperm' starting at row +8 using 4 tile(s), score 20 Possible Top Ten Solution 10: column 2 become: 'spume' starting at row + 8 using 4 tile(s), score 20 C:\Users\tblaz\Documents\evelyn>

    If I were to go farther with this, I'd have to get off the command line. Also, I haven't cobbled together how a person completes a "turn."

    So how can we do this without an indirection operator on the command line?

      Also, I haven't cobbled together how a person completes a "turn."

      After I decide which of the top-10 solutions I want to use, I then use a text editor to fill in the game file (and then enter my awesome super-scoring turn into the Words With Friends app). Once the other player goes, I enter their play into the game file, and update my available tiles, and run again.

      So how can we do this without an indirection operator on the command line?

      The original interface was designed for STDIN/STDOUT interaction. You can see in the test suite (t/03_input_processing.t) the sub run_game(), which shows one way of redirecting the filehandles so it can use a named file instead of relying on the console for input.

      Back when I was actively working on it, I was planning on eventually doing new frontends (like a web interface) as sub-modules that can inherit from the main. But since it worked as-is for me (and I just set up a batch script that converts run.bat game1.txt (or drag-and-drop game1.txt onto the .bat) to perl rungame.pl < %1 to convert to redirection for me, it never became a priority. Similarly, I was planning on writing up instructions for users to be able to define their own gameboards, but never got around to that documentation, either.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11105799]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2024-04-20 04:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found