...again, I will save vertical space for respondents

Did you copy the dictionary file from Win to Linux without removing the \r's ?

No, I did not, tybalt89. After reading your response, I used one of the many ways to convert newlines between dos and unix. This change allowed the one player game to work.

Then I thought, gosh, maybe if I tried to run this script on linux, I might get better behavior out of the multiplayer game, and low and behold, the multiplayer game worked, which is as far as I've been able to replicate. I've been spending time testing, reading, littering the script with say statements.

As script lengths are getting longer and new versions become relevant, I populated a github repo with what I have now. I'm curious whther others can download and get it to work on their *nix systems: github repo.

At some point, I'm going to need to look closer at syntax that I simply don't understand. Let me just pull out some lines of code that continue to baffle me.

We could start here:

    $board =~ /(?<!\w).{2,}(?!\w)(?{ push @pat, [ $-[0], $& ] })(*FAIL)/;

Q1) Can someone talk through what happens on this line? The sorted patterns in @pat look like this:

patterns---------------- ( [0, "..e......."], [11, "..m......."], [22, "..e......."], [33, "..r......."], [44, "..o......."], [55, ".m........"], [55, "..i......."], [55, "...d......"], [55, "....d....."], [55, ".....i...."], [55, "......e..."], [55, ".......s.."], [66, "..d......."],

Another section of code where I lose my grip is here:

my $underpat = qr/[^@under@tiles]/; say "underpat is $underpat"; my @words = grep { length $pat == length $_ && !/$underpat/ && /^$pat$/ && ( ( $old ^ $_ ) !~ /^\0+\]$/ ) # adding just an 's' no +t allowed

Typical output for underpat looks like this

underpat is (?^u:[^mh h i m q r t]) underpat is (?^u:[^mh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^e m e r o i dh h i m q r t]) underpat is (?^u:[^dh h i m q r t]) underpat is (?^u:[^dh h i m q r t]) underpat is (?^u:[^dh h i m q r t])

I would think that this $uderpat represents the tiles that are underneath a word. Q2) Why consider a pattern that throws in the tiles from one's hand? Q3) How does the ultimate line prevent a singular s from being appended whilst not mentioning the letter 's'?

say "new mask is $newmask"; substr $heights, $pos, length $highs, ( $highs & $newmask ) =~ tr/0-4/1-5/r | ( $highs & ~$newmask );

The output from this tells me that I'm not intended to view it. Q4) Seek comment unraveling the logic of the mask.

I've got more questions, but I've got to get moving. At the same github repo, I have several different versions of the script. 3.say.pl might be the best way to view these data on STDIN. The way I want to take things in indicate my 2.mp.pl, where functions are herded into a package. So far, I am not calling them correctly, but I keep making inroads.

One feature that this lacks so far is keeping of time. So I've introduced POSIX. Also, I like bliako's idea of determining a state and making the game a series of these snapshots. 3.say.pl creates a path for games to go in. It also has the tiles with their new "correct" frequency. I was horrified to open up the tiles and see a 'Qu' tile. I'm just going to reject the 'u' in that tile as a recent uglification of this game.

I wanted to write this up all perfect including the specification, but I have to take a detour to understand this code on every line yet.

Thanks for your comments


In reply to Re^2: implementing a scrabble-esque game on Termux III by Aldebaran
in thread implementing a scrabble-esque game on Termux III by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.