Perl: the Markov chain saw | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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 In reply to Re^2: Inputing vectors into a scrabble-esque game
by Aldebaran
|
|