CS160 Program 1 Tic-Tac-Toe
Due Monday October 1, 2001 MIDNIGHT
Submit Prog1 directory using CATS Submit Program
Objectives:
Become familiar with OpenGL at a very basic level.
Learn basic text and interaction handling with GLUT and XForms, basic
shape drawing and coloring in OpenGL.
Assignment:
- The files under the Notes section will be
as the basis for your homework.
- Replace the items drawn in the graphics window with a
3x3 grid representing a tic-tac-toe board. That is, draw two
vertical lines and two horizontal lines to equally divide the
window into pieces. Make the window a pretty background color.
- The Read File xform button should read in a file showing
the initial configuration of the board. The file
Config.file
gives one such configuration. The file is ascii, and has
9 lines. Each line contains X, O, or is blank. This gives
the initial values of the grid.
- The user is X. When the user clicks the left mouse button
in a particular grid square, an X will appear there if the grid
is empty. If the grid is already in use, the user forfeits the
game. Whenever the user successfully enters an X in a new spot,
the computer will automatically fill in a O in another empty spot.
The computer does not have to be smart about this.
- If the user manages to get 3 successive X's in a row, column,
or diagonal, she wins. If the computer manages to do this,
it wins. When someone wins, the computer should announce it
in the Unix window (or on the xform).
You will need to create an appropriate data structure
to hold the present state of the board.
- You must also add a xforms button called
Restart
which clears the board and restarts the game.
- Add the ability to use a command line argument "-s xres yres"
that sets the window size.
- For extract credit, keep track of wins and losses and
show them on the xforms. A smart computer is also worth extra credit
(i.e., one that places its O's to confound the user.
Notes:
- Use the example code given and build on it.
You need
prog1temp.c,
prog1_gui.h (created by fdesign),
prog1_gui.c (created by fdesign),
prog1_gui_cb.c (created first by fdesign),
prog1_gui.fd (created by fdesign),
disp_utils.h,
disp_utils.c,
xforms_utils.h
xforms_utils.c and
the Makefile.
The sample configuration file is Config.file.
- You MUST use C or C++ to do this and you MUST submit a program that
compiles and runs on the BE 105 Suns.
- Submit. Submission must be done using
the submit utility from CATS. Run "quickhelp submit"
or "submit -m"
on a CATS machine to get more info on the submit command.
To submit the assignment, do the following:
- Create a DIRECTORY called "
prog1". It should
contain all the files required to make your program
compile/run.
- Run "
make clean" in the directory to ensure you
do not submit .o files or the compiled program.
- From prog1's parent directory (if you are in the prog1
directory, type "
cd .."), tar the directory with
the command "tar cvf prog1.tar prog1".
- Compress the tar file with the command
"
gzip prog1.tar". This will produce the file
"prog1.tar.gz" which you will submit.
- To submit your solution, use the command
"
submit cmps160-jw.f01 prog1 prog1.tar.gz"
- With your homework, please be sure to include a Readme
file explaining how to compile and run your program. Also,
remove the "temp" from the name of the program and files.
Please sure that it will run on the BE 105 Suns.
- New - Monday, 9/24 To give you something to compare your work to,
here is a sample solution by dbrooks.
prog1.
You have to chmod it to 755 to make it
executable.
Questions? E-mail