JavaScript Assignment
Fall 2002, David Matuszek
Your assignment is to write a JavaScript program, embedded in an HTML web page,
to play Tic-Tac-Toe (Naughts and Crosses).
Your program does not have to play a winning game of Tic-Tac-Toe. Although
Tic-Tac-Toe is easy to analyze, a program to play well would be very lengthy.
I would like you to concentrate on the JavaScript aspects, such as event handling
and providing a reasonable user interface, rather than in the game logic. The
game logic would be the same regardless of the programming language
Here's what your program should do:
- The program should play in a 3x3 grid, so that it looks at least sort of
like a Tic-Tac-Toe board. It is not required that the playing board look exactly
like the usual #-shaped board.
- It would be nice, though not required, to play with Xs and Os. However,
any distinguishable marks or changes will be acceptable.
- The program must be able to play multiple games, not just one.
- The computer should not start every game. It's OK if the human starts every
game, or if the first player can vary.
- The program should recognize when someone has won the game, and display
a message indicating who won.
- Most of the logic should be in functions in the head of the HTML page.
- As there are many different ways the Tic-Tac-Toe board could be displayed,
the game logic and the display code should be as cleanly separated as possible.
- It would be nice, though not required, that your program keep a tally of
how many games were won and lost during this visit to the web page.
Due date: Thursday, November 21, before midnight. Please turn in by
Blackboard, and don't post to your course web page just yet.