February 9th, 2016
Tic Tac Toe program is due on 2/11/16.
Keep in mind programming style tips we have been discussion since the beginning of the year:
1. Documentation: COMMENTS – the header and a short line in each function definition.
2. Naming: use relevant names for variables and functions.
3. Test all possible scenarios to make sure every part of the program executes successfully.
NOTE: TO MAKE IT MORE INTERESTING AND INVITING TO THE PLAYER, MAKE THE FIRST COMPUTER MOVE RANDOM. However, it should be intelligent once the game is on.
A- 1 day late
B+ 2 days late
B 3 days late
B- 4 days late
C+ 5 days late
C 6 days late
C- 7 days late
D+ 8 days late
D 9 days late
D- 10 days late
F 11 days late
0 after 11 days pass the due date
I encourage you to talk to me ahead of time if this is a problem.
These two functions can be borrowed from the author’s program:
def drawBoard(board): # This function prints out the board that it was passed. # "board" is a list of 10 strings representing the board (ignore index 0) print(' | |') print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9]) print(' | |') print('-----------') print(' | |') print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6]) print(' | |') print('-----------') print(' | |') print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3]) print(' | |')
and
def isWinner(bo, le): # Given a board and a player's letter, this function returns True if that player has won. # We use bo instead of board and le instead of letter so we don't have to type as much. return ((bo[7] == le and bo[8] == le and bo[9] == le) or # across the top (bo[4] == le and bo[5] == le and bo[6] == le) or # across the middle (bo[1] == le and bo[2] == le and bo[3] == le) or # across the bottom (bo[7] == le and bo[4] == le and bo[1] == le) or # down the left side (bo[8] == le and bo[5] == le and bo[2] == le) or # down the middle (bo[9] == le and bo[6] == le and bo[3] == le) or # down the right side (bo[7] == le and bo[5] == le and bo[3] == le) or # diagonal (bo[9] == le and bo[5] == le and bo[1] == le)) # diagonal