http://qs321.pair.com?node_id=11108771


in reply to implementing a scrabble-esque game on Termux III

Q2: Did you copy the dictionary file from Win to Linux without removing the \r's ?
That's one of the differences between the two.

Check your cache files, maybe delete and rebuild them.

I run on Linux (ArchLinux) so what I posted works there.

  • Comment on Re: implementing a scrabble-esque game on Termux III

Replies are listed 'Best First'.
Re^2: implementing a scrabble-esque game on Termux III
by Aldebaran (Curate) on Nov 23, 2019 at 18:16 UTC

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

    Thanks for your comments

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

      This is the heart of finding a place to move. For a word to be a legal move, it must match one of the patterns in @pat. The (?<!\w) prevents putting the new word next to a preceding word, and the (?!\w) prevent putting the new word abutting a following word. The(*FAIL) forces the regex engine to try every possible place to find a match.

      Try

      perl -le ' "abcd" =~ /.{2,}(?{print $&})(*FAIL)/ '

      and notice it prints out every substring with two or more characters.

        leaving vertical space for respondents...

        Thanks for your comment,