Inputing vectors into a scrabble-esque game

In a recent thread, using perl to find words for scrabble, we did a survey of what exists and what would be a good continuation. I've had time to replicate what I could get working of the commentors, in particular those who posted source. I was anything but specific about the specification, and with the quality of the responses, I think we can cobble together an application that a) is usable on one's phone, and b) simple enough to use in the context of an actual game. The home run ball is a game that can actually incorporate the logic of the rules and calculate values acccording to this variation that I shall specify. Yet it has to start with something. So let's call that the front end. I'd like that to be the next focus.

The game I'm writing for is called Upwords. I don't think it is well-known. Here are the rules of the game. What might distinguish this variant is that tiles stack up to five high. Let me trot out some source, so as to motivate what I'm asking for. I won't attribute every line to original author. In this one, I have a bit that pryrt and tybalt89 posted in the above thread referenced. We're gonna have to adapt most of it anyways.

use 5.011; use Path::Tiny; my $n = 10; my @board = map{ [('.') x $n] } 0..($n-1); print "Empty board:\n"; foreach my $row(@board){ foreach my $col( @$row ){ print $col; } print "\n"; } use List::Util qw( shuffle ); my @letters = split //, 'aaaaaaaaabbccddddeeeeeeeeeeeeffgggghhiiiiiiii +ijkllllmmnnnnnnooooooooppqrrrrrrssssttttttuuuuvvwwxyyz'; my @tiles = ( shuffle @letters )[0 .. 6]; print "tiles: @tiles\n"; my $pattern = join '', map "$_?", sort @tiles; my @matches = grep join('', sort split //) =~ /^$pattern$/, grep /^[@tiles]{2,}\z/ && /[aeiouy]/, # lc, size & vowel path('c:\users\tblaz\documents\html_template_data\dict\enable1.txt') +->lines({chomp => 1}); print "\nmatches:\n\n@matches\n"; __END__

Typical output:

Microsoft Windows [Version 10.0.17763.805] (c) 2018 Microsoft Corporation. All rights reserved. C:\Users\tblaz\Documents\evelyn>perl 3.letters.pl Empty board: .......... .......... .......... .......... .......... .......... .......... .......... .......... .......... tiles: m l i r p g m matches: gimp gip girl glim grim grip imp li limp lip mi mig mil mim mir pi pig + prig prim rig rim rip C:\Users\tblaz\Documents\evelyn>

What a lucky draw, because this shows how narrow the logic of the game can be as opposed to the way we regard words. The grep line as tybalt89 wrote it is:

grep /^[@tiles]{2,}\z/ && /[aeiouy]/,        # lc, size & vowel

This game has no requirement of a vowel, so 'mm' is taken as a word and does not show in the list of @matches. Obviously, this means removing the && condition.

The empty board could be represented as rows and columns of empty dots, but an array is not gonna have a means to specify its height, so we would have to have something more like what Disciplus suggested:

my @board; foreach my $row(0..14){ foreach my $col( 0..14 ){ $board[$row][$col] = { letter => '.', lett_mod => 1, word_mod +=> 1}; } }

But the whole thing does not get off the ground unless I have some means to input into this data container in real time on my phone. Games::Literati has useful parts, but without some type of front end, using the command line and a text editor is much too burdensome on a phone.

It seems to me that the best way to specify a vector in two-space like this to use alphanumerics, like unto the game battleship. Rows are letters and columns are numbers. while it is appealing to stick a colon in between to signify range, the colon is not a good symbol to input for a phone, because it requires either a shift or another screen entirely. So while it might be visually better to have a2:a6, a2 a6is all that STDIN needs to understand the range.

My question is how do I use STDIN to specify a range and then come back to me and ask me to input a word, which it checks for appropriate length, kosherness as a word, (is kosherness a word?), deposits it into a Disciplus-style array of hashes, and eventually, calculates the value of all the words thus formed?

Thanks in advance,


In reply to Inputing vectors into a scrabble-esque game 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.