Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Inputing vectors into a scrabble-esque game

by bliako (Monsignor)
on Oct 30, 2019 at 23:12 UTC ( [id://11108141]=note: print w/replies, xml ) Need Help??


in reply to Inputing vectors into a scrabble-esque game

If that's one more act in the battle of the sexes (oh the most iconic of the palindromes!), I will gladly give my 2 bits to achieve balance:

How about you have the phone take a picture of the board, reconstruct the board in memory, find best move for you? And optionally looking ahead and minimising the score of your opponent's next move.

I have looked briefly at your previously-related post, its answers and the link provided to an older thread for scrabble, but I could not see a function which searches for words in dictionary when some of its letters are clamped on specific values. I.e. for those letters already set on the board squares where you plan to place your new word. So, can you start with a filter for the results of tybalt89's my $pattern = join '', map "$_?", sort @tiles; to make sure your candidate words have specific letters at specific positions?

Then have another function which calculates the score of each candidate word taking into consideration what's already on board (i think appending to existing words gives you extra credit?). Would that be easier by having that function taking the board state as input, adds your candidate word in it and re-calculates the total board score? Subtracting this from initial score will be your word's score - more or less, right?

bw, bliako

Replies are listed 'Best First'.
[OT] Re^2: Inputing vectors into a scrabble-esque game
by afoken (Chancellor) on Oct 31, 2019 at 11:11 UTC
    ... have the phone take a picture ...

    25 years ago, that sentence would not have made any sense at all. It's quite impressive how the prefered instrument for taking a snapshot has moved from a dedicated, perhaps analog camera to the camera embedded in a smartphone.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Inputing vectors into a scrabble-esque game
by Aldebaran (Curate) on Nov 02, 2019 at 04:39 UTC
    How about you have the phone take a picture of the board, reconstruct the board in memory, find best move for you? And optionally looking ahead and minimising the score of your opponent's next move.

    I would love to be able to use phone technology in such a manner. These might be my first tepid steps to coding for this device. I'm always glad to entertain asides and "what are we on the cusp of" discussions, provided that we're also addressing the main topic of the thread.

    but I could not see a function which searches for words in dictionary when some of its letters are clamped on specific values. I.e. for those letters already set on the board squares where you plan to place your new word.

    I have some ideas on how to deal with that clamping. Our algorithm would move bottom to top for possible placing of vertical vectors, and right to left if they are horizontal. I would think that that would create analogous logic for the two cases. You either have to place your tiles vertically, or horizontally, but never both.

    So, can you start with a filter for the results of tybalt89's my $pattern = join '', map "$_?", sort @tiles; to make sure your candidate words have specific letters at specific positions?

    The resulting string is simply the tiles with a question mark as padding. I didn't find that useful for this version.

    Then have another function which calculates the score of each candidate word taking into consideration what's already on board (i think appending to existing words gives you extra credit?). Would that be easier by having that function taking the board state as input, adds your candidate word in it and re-calculates the total board score? Subtracting this from initial score will be your word's score - more or less, right?

    I've started with a calculation function and "gotten on the proverbial board." Let me trot out some output then source next:

    Questions:

    Q1) How do I print the board by showing the letter value in the hash stored at each array location?

    As I'm looking at what I have, I realize what I want for the board. It's to have the column numbers displayed in the first row and the row letters displayed in the first column. We could put a character in the corner like a black square. Thus, the array of hashes will be 11x11, but the values will no longer be zero indexed in a way that needs to be accounted for.

    Q2) How do I best create these arrays?

    Q3 How am I getting greater than 7! = 5040 values from the uniq call on 7 tiles?

    Q4) How to I take the best word that %found has and insert it into the array of hashes at, say, the sixth row beginning at the third column and going right? We are guaranteed to have enough room for the first word. It is the only one that can be played without touching the previous graph at some point. (no floaters after the first one).

    Thanks for your comments

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 22:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found