How to place BLANKS in Scrabble board when it affects the points in a play - scrabble

Is there a general rule in scrabble that states that optimal points be awarded to plays dealing with BLANKS and premium letter squares?
Let's say for example that my rack has the following:
RACK
So we use some tiles to create a word PIZZA. Obviously I only have one Z, so it makes sense to use the BLANK on the non-premium square to create the word. The issue is where the BLANK is placed!
SCRABBLE BOARD
Is this left up to the discretion of the player to put the BLANK in the correct place or do the rules mandate its placement based on giving the play the most points?
I can see some strategic reasons why placing the blank will differ from scenario to scenario but just want to understand how this works for the rules.

Related

Game playing AI, how to find a good board evaluation function?

I'm working on an AI to play a fairly simple game, using minimax and genetic algorithms to find weights to score board states with.
The game resembles 4x4 tictactoe, but a turn can be spent to move a piece to an adjacent space, pieces come in different sizes, and larger pieces can cover up smaller pieces.
I want to score the board by looking at a variety of factors, such as how close they are to completing a 4 in a row, and how many adjacent enemy pieces could potentially be moved onto, but I have no idea what these factors should specifically be.
My ideas:
For each line, making a scoring expression based on number of friendly pieces, number of empty spaces, and number of enemy pieces, but I can't think of a simple expression to score that with weights, since the value probably won't be a linear function.
For each line, making a piecewise scoring expression split based on the number of enemy pieces in the row, and an expression based on the number of allies. Hence having 1 piece in an empty row might be worth more than having 1 piece in a row full of enemies, thus blocking them off, and the inverse would be true for having 3 in a row in a row that is already blocked.
Some complications I've noticed:
Having 3 pieces in a row, but then one of the enemy large pieces also in the row, is virtually worthless for anything except preventing their piece's movement.
Having 3 pieces in a row, with a small enemy piece in that row is almost a win, if you can place a large piece adjacent to their small piece to move onto it. This seems particularly hard to detect. It's also possible if this is worked into a factor, the above "number of adjacent enemies that can be moved onto" won't be necessary.
Thanks for any help. I have no clue how to proceed.

effective way to store and access an existing list of videogame characters with counters and synnergies with C++

I'm attempting to make a DotA drafting companion application in C++
I'll give you a little run down of how it will work. In DotA there are two teams of 5 players. No character can be picked twice in a single match, meaning teams cannot share a character. It is important to keep in mind both your team's and opponent's picks. So what this will do is suggest characters for you to pick based on your and your opponent's teams.
To clarify, the existing list is not some sort of database, just a menagerie of suggestions on various websites, forums, and videos. I would be organizing the list myself, and so my question is ultimately what format should I create this list in?
So for instance a popular character is Phatom Assassin who is strong with characters who can reduce armor, and weak against characters who can do lots of damage.
So a hero class might look like this
class DotaHero
{
Name = "Phantom Assassin";
vector<DotaHero> Counters{"Lina", "Lion"};
vector<DotaHero> Friends{"Templar Assassin", "Shadow Demon"};
CImg<unsigned char> src("PA.jpg");
}
My program would allow you to input the first few heroes and then display a list of characters as a suggestion.
Should I...
Create a class for each and every hero in the game
Stream from a text file with each hero delineated by counters/friends
Create some sort of database to store each hero's counters/friends in
Please feel free to give any suggestions!
A very difficult question.
The question of what you store and how your express relationships between characters is going to define fundamentally how your tool works and how effective it is.
Of the top of my head I would create 2 weighted graphs,
1.) friends.
2.) counters.
Each node represents a hero and each edge of the graph would correspond to how strong of a counter or how strong of a friend you consider that hero. As heros are picks, find the highest weighted neighbor node to all of the current picked hero, and this would be your highest weighted suggestion. That would be the naive approach based only on the next pick (not always the best, a good way to get into trouble). Add layers and create weightings for 2nd order neighbors and you can start doing non deterministic analysis of the data set to get more sophisticated results.
Just a jumping off point. It would be a truly fascinating problem.

Golf Tournament Pairing Algorithm

Idea is simple. Function needs one argument which is the players amount. It generates the graph where each player is placed versus another one (screen included). If players are even, rounds equals to players-1 else, it equals players.
I've noticed that the best way to do the pairing is to change order of numbers (source).
I can't find any solution to make it work with uneven player's count. Any suggestions are welcomed, as I really need this algorithm to start working ASAP. It looks simple, and won't take much coding, so it's not an issue. I just need the tip.
If you have an odd number of players, add a dummy player. Whoever plays the dummy player in a certain round, doesn't compete in that round.
You can even see that in your example image where player 6 is the dummy. The left table is obtained by skipping all matches versus number 6.

How do I correctly check for castling in chess AI?

I have a chess AI that doesn't always know if it can castle or not. The rooks and kings have move counters that only allow them to participate in a castle when the value of the move counter equals zero. A problem occurs when the move counters are zero and there are no pieces blocking the castle, but an enemy piece has the ability to block the castle from afar.
For example, imagine that you are white and you want to make a queen side castle. The move counters are zero, so your pieces have made zero moves, and your white knight, bishop, and queen are gone. The you thinks that you can castle. But you actually cannot castle because there is an enemy rook with a clear line of attack that extends all the way down to the first row where you have your white rook and white king. If you castled, the king would have to cross the black rook's line of attack. You are the AI and this situation messed you up.
Now you [the human] might know a way to make you [the AI] smarter when it comes to castling. How would you, as a programmer, fix this problem such that the AI doesn't make this mistake anymore?
Here's some more information...
My board representation is int board[8][8]. I have an array that holds all possible white pieces [max 2 queens, 17 pieces total], int whitePieces[17], and array that holds all possible black pieces, int blackPieces[17]. Also, to keep track of movement, there is a moveTo[] array and a moveFrom[] array that contains, for each ply, a copy of the moving piece after it moved and before it moved. The rightmost bit of the piece integer is the y value and the 4 bit hexadecimal value one over from that is the x value. The integer piece also contains byte data representing the piece type, the piece color, the pieces location in the whitePieces array or the blackPieces array, and a movement counter that keeps track of the number of moves and is used to determine if a king or rook has moved and thus cannot castle.
Your AI should have some sort of 0-ply "threat grid" that shows where every enemy piece can move next turn. Use this info to see if the squares between the king and rook(s)the final castling location(s) are either occupied or under threat.
Had same problem long time ago (1978 - in fortran).
Aside from the tests you all ready mentioned (had select rook moved, had king move, is row between them empty) you need to insure:
The king is not currently in check.
With the code that determines if the King is in check, that same code can be use to see if a king would be in check in the 2 squares of interest. So "pretend" to move the king, 1 space at a time 2 spaces left (or right) and run the test.
2 other pedantic thoughts:
The flag that sets when a rook is "moved" also needs to be set is the rook is taken. Testing to see if a rook is in the corner is not enough as it could be another rook.
A pawn promoted to a rook and then not moved cannot be used for castling. castling on a file
Notes:
Rather than 17 pieces, consider staying at 16. (You can have 0-9 queens, 0-10 rooks, 0-10 bishops, 0-8 pawns, 1 kg, etc.)
The space the rook is on or passes through may be threatened from the other side.

Is there a way to rank the difficulty of pronunciation of a word?

I'm trying to build a collection English words that are difficult to pronounce.
I was wondering if there is an algorithm of some kind or a theory, that can be used to show how difficult a word is to pronounce.
Does this appear to you as something that can be computed?
As this seems to be a very subjective thing, let me make it more objective, let's say hardest words to pronounce by text to speech technologies.
One approach would be to build a list with two versions of each word. One the correct spelling, and the other being the word spelled using the simplest of phonetic spelling. Apply a distance function on the two words (like Levenshtein distance http://en.wikipedia.org/wiki/Levenshtein_distance). The greater the distance between the two words, the harder the word would be to pronounce.
Great problem! Off the top of my head you could create a system which contains all the letters from the phonetic alphabet and with connected weights betweens every combination based on difficulty (highly specific so may need multiple people testing and take averages etc) then have a list of all words from the English dictionary stored on disk and call a script which cycles through each entry and performs web scraping on wikipedia for the phonetic spelling and ranks their difficulty. This could take into consideration the length of the word as well as the difficulty between joining phonetics then order the list based on the difficulty.
Thats what I would try and do :P
To a certain extent...
Speech programs for example use a system of phonetics to try and pronounce words.
For example, "grasp" would be split into:
Gr-A-Sp
However, for foreign words (or words that don't follow this pattern), exception lists have to be kept e.g. Yacht
Suggestion
Fortunately Pronunciation as a process is dependent on a two factors these include
the phones making up the words and the location of vowels and semi vowels i.e
/a/,/ae/,/e/,/i/,/o/,/u/,/w/,/j/...
length of the word.
the first relates to the mechanics of phone sound production as the velum, cheeks tongue have to be altered to produce various sounds related to individual phones i.e nasal etc. this makes some words more difficult to pronounce as the movement required may be a lot. Refer to books about phonetics to find positions of pronouncing each phone.
Algorithm
a weighted spanning tree with weight being the difficulty of pronouncing two consecutive phones i.e l and r or /sh/ and /s/
good luck.

Resources