CS 115 Project 2, Spring 2015:
Tic-Tac-Toe


Summary

In this project, you will allow two users to play a variant of Tic-Tac-Toe on their choice of board.

Due dates

Checkpoint ADue as an in-person demo in tutoring, lab, or workshop; see the Moodle schedule for times. Your last chance is the workshop on Thursday, March 12.
Checkpoint BDue as an in-person demo in tutoring, lab, or workshop; see the Moodle schedule for times. Your last chance is the workshop on Thursday, March 26.
Final codeDue on the CS department server (see Moodle instructions), on Tuesday, April 7 at 11:00 PM

Getting Started

Because this program is graphical, you will need to run it using IDLE on your local machine. Download graphics.py into your Python directory.


Checkpoint A (7 points)

Specification

Examples

Sample 1

Window side length in pixels: 50
Error: must be a number between 100 and 1000.

Sample 2

Window side length in pixels: 400
Number of squares per side: 50
Error: must be a number between 3 and 40.

In this sample, the upper limit of 40 comes from 400 divided by 10.

Sample 3

Window side length in pixels: 400
Number of squares per side: 4
Squares in a row to win: 4

Here is the blank board your program should draw:
Blank tic-tac-toe board

Hints:

To exit a program immediately, import the sys library. Then, you can use sys.exit().

To draw the grid, you will want to use the Line data type from graphics.py. You may want to review Lab 5 to see how this data type is used.


Checkpoint B (8 points)

Specification

Sample 3

Window side length in pixels: 400
Number of squares per side: 4
Squares in a row to win: 4
Player 1: click a square.

Here is the board before Player 1 clicks:
Blank tic-tac-toe board

Here is the board after Player 1 clicks:
Board after Player 1 has clicked

Player 2: click a square.

Here is the board after Player 2 clicks:
Board after Players 1 and 2 have clicked


Final Code (55 points)

In your final code, you will extend your checkpoint code in the following ways:

Hint:

One easy way to keep track of what the players have clicked is to use a 2-dimensional list. Initializing a 2D list is a little bit tricky in Python. Here is an example:

size = 5
board = [[0] * size for i in range(size)]

This creates the following 2D list:

[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

You can access an individual element by using two index values: one for the row, and one for the column. For example:

board[0][2] = 2

changes the list to:

[[0, 0, 2, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]

There is no demo for your final code. See the end of this specification for submission instructions.


Grading

Correctness [55%]

The most important part of your grade is the correctness of your final program. Your program will be tested numerous times, using different inputs, to be sure that it meets the specification. You will not get full credit for this 55% unless your output is grammatically correct, correctly spelled, and professional.

Programming Design and Style [30%]

In addition to being correct, your program should be easy to understand and well documented. A detailed grading sheet for this part of your project is posted at
http://rivoire.cs.sonoma.edu/cs115/proj/cs115_p2_rubric_partial.html

This grade sheet is different from the Project 1 style grading sheet. In particular, you will lose a lot of points if you don't design and use at least one function of your own.

Note that there is an automatic style checker on cwolf that can check some aspects of programming style for you. For details, see the grading sheet link.

Checkpoint [15%]

Your checkpoints are worth a combined 15 points, as described above. The checkpoints cannot be submitted late.

Extra credit [up to 5 points]

There are lots of possibilities to extend this project for extra credit. If you have an idea you'd like to implement, run it by Dr. Rivoire.


Submitting your final code

If your project code is on your computer, you must copy your final code to the CS department server using FileZilla BEFORE following the instructions in the next paragraph. Every lab has instructions on how to do this.

Once your project code is on the cwolf server, you must submit it for grading by logging onto cwolf and running this command:

~srivoire/bin/submit 115

Type P2 when prompted for the assignment, and then type the name of the file you want to submit. Be sure that you confirm your submission by visiting
http://rivoire.cs.sonoma.edu/cs115/submit/proj2.txt
and looking for a file with your name, your cwolf username, and the correct timestamp.

You may resubmit as many times as you like, and only the last submission before the due date will be graded.

Collaboration policy

Programming projects must be your own work, and academic misconduct is taken very seriously. You may discuss ideas and approaches with other students and the course staff, but you should work out all details and write up all solutions on your own. The following actions will be penalized as academic dishonesty:

Late policy

There is a 48-hour grace period associated with the final project deadline. This grace period is designed to cover small personal emergencies and other unexpected events. No other consideration will be given for these small emergencies.