15-112 Spring 2013 Homework 6
Due Tuesday, 26-Feb, at 9pm
+5-point Early-Bird Bonus if submitted by Monday, 25-Feb, at 9pm


Read these instructions first!
  1. [25pts] Do the following problems from f12 hw5a:
    1. solvesCryptarithm
    2. bestScrabbleScore
       
  2. [25 pts; 4 pts each + 1 free pt] Do any 6 problems of your choosing from f12 hw5b. These are SOLO, not collaborative, despite what f12 hw5b may say. The problems you elect not to do still make for excellent study problems for upcoming quizzes and exams. As usual, place your solutions in a triple-quoted string at the top of your hw6.py file, and be sure to show your work!
     
  3. [25 pts] Othello
    1. Find an online Othello game and play it for a while, until you are comfortable with the rules.
    2. Study the othello.py code from the case study we covered in class. You should study it thoroughly since both wordSearch and Othello are now likely to appear on upcoming quizzes and exams (and not just appear, but perhaps play a central role).
    3. [4 pts each + 1 free pt] Make the following changes to the code. Except as noted for printBoard, do not change the names of any functions, nor the names or number of parameters those functions take. Otherwise, the autograder will not work!
      1. Fix getMove so that it works properly up to a 26x26 board. Right now, it fails if there are more than 9 rows.
      2. Add the function getLegalMoves that takes a board and a player and returns a list of all the legal moves for that player as a list of (row,col) tuples, sorted first by row and then (for the same row) by column. If there are no legal moves for that player, return the empty list.
      3. Change printBoard to display legal moves as a dot (“.”) rather than a dash (“-“).  To do this, you should add an additional parameter to printBoard, so it takes both a board and the currentPlayer.
      4. Change the game (again, without changing any function names or parameter lists) so that it works with wraparound, so for example, if you head off the board on the right edge, you re-enter on the left edge. Wraparound must work across all 4 edges (left, right, top, bottom), and then in all 8 directions.
      5. Modify playOthello so that it displays the current score as the game is played (the score for each player is the total number of pieces that player has on the board at that time).
      6. Add the function playOthelloAgainstRandomComputer(rows, cols), that works just like the just-modified playOthello, only player O is the computer, which makes random moves from among the legal moves available to it.
         
  4. [25 pts] The Memory Game
    In this game, an RxC rectangular grid is filled with random numbers such that each integer from 1 to RC/2 occurs exactly twice. Numbers are hidden. On each turn, the player uncovers two numbers. If they match, they are unhidden (so the player can see them). Play ends when all the numbers are unhidden. The score depends both on the number of incorrect guesses and the total time required. Write the function playMemoryGame(rows, cols) that implements this game as described. Follow this spec when you can, but there are also a lot of decisions left up to you. In any case, make your game reasonably attractive and playable, though we understand that console-based games have their limitations. Also, include a ‘help’ command that explains how to enter commands.
    Note: we will only test this up to 26x26 grids (so you don't have to deal with column AA...).

carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem   -   carpe diem