Assignment: Tic Tac Toe

Entertain me, computer

The Problem

Write an interactive Tic Tac Toe game.

Submit through blackboard:

  • Two code files, one for part I and one for part II
  • A text file with test runs that show your code reasonably works
  • A text file with a brief write-up (couple paragraphs) explaining how you approached the problem, obstacles you hit, and citing any resources (books, online, people) that you used while working on this assignment

Googling for a python tic tac toe game and copying it is cheating. Looking at someone else's code will influence how you write yours, and likely result in copying it whether intentionally or not. The correct thing to do is google for similar examples and work from those.

The tests and write-ups account for 50 pts.

You may continue to work with the partner you started the lab with if you are actually working on the code together, not merely sharing it. If you work together, you are turning in one set of code files and tests, but each partner do your own write-up and include a comment on how you worked together. So either partner can submit the files, but the other should still submit a write-up.

Part I. The Two Player Game (300 pts)

This is the main part of the assignment, and it follows directly from the lab. Create the working two player game, with win and tie conditions. How you design the user interaction is up to you, as long as it communicates the game effectively. Here's mine in action:

X's turn!
 Where would you like to move (0-8)?: 0
X| | 
 | | 
 | | 
O's turn!
 Where would you like to move (0-8)?: 4
X| | 
 |O| 
 | | 
X's turn!
 Where would you like to move (0-8)?: 1
X|X| 
 |O| 
 | | 
O's turn!
 Where would you like to move (0-8)?: 6
X|X| 
 |O| 
O| | 
X's turn!
 Where would you like to move (0-8)?: 2
X|X|X
 |O| 
O| | 
X wins!

I recommend that you work your way up from the simplest version of the game, as we did in the lab. See the lab for further details.

Part II. The One Player Game (200 pts)

Submit this as a separate code file.

Modify your part one game so that you can play against the computer. Points will be given for:

  • Working 1-player game, the AI is complete enough to finish the game
  • AI that actually plays better than random
  • AI that cannot be defeated, only wins or ties (extra credit)