italian kitchen tiles design
with this homework we're back to scrabble, and we're tackling the problem of blank tiles. you probably thought this was coming. we talked about blank tiles as we were trying to design the program. if you remember back to playing poker, i threw the problem of jokers at you. blank tiles are similar to jokers. they can be played, and any letter can take the place of the blank tile. you get to choose which letter you want to replace this with. but we can't use exactly the approach that we used with jokers of saying well let's just try all 26 possibilities one at a time without changing the code
and then just take the maximum play over the those, say, because the scoring rules are different. suppose we wanted to play the word sway. we could use the blank tile to form a y, but if we had a real y tile, that would worth 4 points, whereas if we have a blank y tile that's worth zero points in terms of the letter score. we can't just replace it as-is. we have to keep track of the scoring. we have a question of how we're going to represent the blanks. now, i'm going make some of that choice for you.
i'm going to say that in the hand, which is the string of seven characters, the blank tile is going to be represented by an underscore. on the board, when you finally decide what you're going to play-- let's say you decide that the blank is going to be represented by a y-- we're going to go ahead and represent that as a capital letter y, because once it's played, it fully takes on the affect of the letter it replaces. so somewhere from going to the hand to going to the board, the blank changes from an underscore to a capitalized letter, but in between it's up to you.
now, as the program progresses, we call best_play, which calls all_plays, and at some point we're going to call calculate_score. it's up to you to decide what format and what type of data you want to pass to each of those functions. one possibility is you can maintain the underscore as representation for a blank. at some point you might want to swap over and use the capital letter that you've chosen to replace it with. you also have the option of using a lowercase letter, and that has the advantage of, one, it tells you what letter i've chosen, but also it distinguishes the lowercase letter, which represents a blank and would score zero
from the uppercase letter which does not represent a blank and would score 4. you decide which combinations of these you want and which functions you have to modify in order to successfully make the best play, the best choice for using a blank or not using it if the best play is to not use a blank in your hand to score the maximum number of points. here are some examples. here's the directions for what you should do. assume that all the code is loaded, and just write the functions and maybe updates to variables that you need. then make sure you can pass at least these tests,
but you probably should try out some additional tests of your own. make sure that you haven't broken best_play() and that it still gets the same result for the test that we did before. when one letter is a blank you actually score a little bit less, because the a scores no letter points. now, i've chosen to show here the lowercase letter to indicate where the blank is played, but your function that returns best_played doesn't necessarily have to return a representation like that. it could have returned a blank character there or something. as long as we know that the score is correct and the best play is correct.
when there are two blanks, we could have continues to create bankbench with two blanks in it, but it turns out that another play-- making kick and taking advantage of some triple bonuses scores higher.