15-112 Fall 2014 Homework 7
Due Sunday, 12-Oct, at 10pm

Read these instructions first!
  1. isLegalSudoku(board) [25pts] [autograded]
    Do isLegalSudoku from here.

  2. friendsOfFriends(d) [20pts] [autograded]
    Do friendsOfFriends from here.

  3. playSudoku(initialBoard) [55pts] [manually graded]
    Note: your solution to this problem must use the MVC-style version of our Basic Interactive Graphics that we covered this week, and also must use the isLegalSudoku founction you just wrote.

    With this in mind, write the function playSudoku(initialBoard) that takes a 2d list representing a Sudoko board, as described in isLegalSudoku, and lets the user play an interactive, graphical Sudoku game starting from that board. The game must be implemented using our Basic Interactive Graphics code, which you must import (below the #ignore_rest line, of course). The user interface is left to you, and can be either mouse-based, key-based, or some combination, with these requirements:

    • Your game must work for a 1x1 board, a 4x4 board, or a 9x9 board. We will not test other sizes.

    • Your game must have a help screen, which is displayed when the user presses either "h" or "?", and all the legal commands (as described below) must be explained on that page. Note that this is actually the same screen and window as your game, just that you should display help info at times, and the game at other times. Hint: it may help to have a variable canvas.data.inHelpScreen that is initially False and set to True when the user presses "h" or "?".

    • You need a way for the user to place a number in a cell, and to change the number in a cell.

    • You need to clearly display to the user if a move or a board position is illegal.

    • You need to display when the board is solved.

    • You need to provide a simple undo/redo mechanism (that allows for undoing an arbitrary number of steps, all the way back to the initialBoard, and then redoing those steps, if that's what the user wants).

    • You need to provide a simple timer or counter that somehow continually (say, at least once per second) updates to show how long the user has been trying to solve the given puzzle. This will require using timerFired. It is the only place you need to use timerFired for this problem.

  4. Bonus/Optional: play2048() [5 pts] [manually graded]
    Using our basicAnimation framework, write the function play2048(), that plays a fairly close knock-off of the game at this web site. For full credit, include the animations.

Here are some hints and clarifications: