View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Spring 2006 Programming Assignment 1

Due: Monday, 23 January 2006
Sudoku is a Japanese logic-puzzle that has recently become quite popular. The aim of the puzzle is to enter a numerical digit from 1 through 9 in each cell of a 99 grid made up of 33 subgrids (called "regions"), starting with various digits given in some cells (the "givens"). The digits must be assigned in such a way that no row, no column, and no region has more than one instance of any digit. Figure 1 shows a Sudoku puzzle (givens are shown as dark gray cells):

Figure 1
Figure 1: A Sudoku Puzzle
Figure 2
Figure 2: The Solution

Figure 2 shows the same puzzle as Figure 1, but it is solved. Both 1 and 2 were created with the Squeak Sudoku, available below. For programming assignment 1, you are to extend the Squeak Sudoku to make it easier to solve as follows:
  1. Show visually whether a cell is invalid. A cell is invalid if some other cell in its row, column, or region has the same value. These should update automatically whenever a new value is entered.
  2. Complete the score function. In the original version, there is a placeholder <updating score> for the score. The score should display how many cells are blank and how many cells are invalid. When no cells are blank or invalid, inform the user that they have won.
  3. Complete the AutoScan mode. In the normal mode, blank cells are empty and clicking on the cell changes its value to the next value (blank, 1, 2, 3, 4, 5, 6, 7, 8, 9, blank). In AutoScan mode, the row, column, and region scans are done automatically. Blank cells display (in grayed text) the values that wouldn't make any of its neighbors (in column, row, or region) invalid. Clicking on the cell changes its value to the next valid value, based on those scans.
Figure 3 shows how these changes might look. Invalid cells are highlighted in yellow. The score is red as there are invalid cells. In AutoScan mode, the possible valid numbers for each blank are shown as grayed out.

Figure 3
Figure 3: The Goal of Assignment 1

The Squeak Sudoku

To use the Squeak Sudoku, first download the code and install it. To file in the code, open a file list (World Menu::open...::file list), find and select the Sudoku-initial.st file; click the filein button to install the code. Next, open a new SudokuMorph. You can either execute SudokuMorph new openInWorld or go through the menus (World Menu::new morph...::from alphabetical list::S-S::SudokuMorph). Then, you can open one of the example puzzles available below. Download the puzzle(s) to your Squeak directory; when you click on the central dot on the SudokuMorph, a menu will come up that allows you to open the puzzles (and even create new ones).

Dealing with MVC (Model-View-Controller)

The Sudoku version provided uses the MV paradigm of MVC—it separates the model from the view. SudokuPuzzle and SudokuCell form the model. SudokuMorph and SudokuCellMorph form the view. To see how this works, check out these methods:
You can use a similar mechanism to do all of the other communication for this programming assignment. For instance, when the validity changed, call self changed: #valid and deal with it.

Grading Criteria

Collaboration Policy

You are not allowed to share your code with others in this class. You can give or receive incidental help (but not code) from others. This is an individal assignment; you turn in your own code. The only exception to this rule is if you want to complete this assignment using pair programming (read this page if you are interested).

Turn-in Site

Questions?


Links to this Page