Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

...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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 06:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found