The Game of War
Please save the following files (in a new directory):
game.h
main.c
game.c
makefile
Now get into emacs by calling
%e main.c&
Compile the program by
M-x compile
Emacs will suggest using make -k for compilation,
agree by hitting return.
If you run a program now, it will prompt you for step.
Your program will show you the results of the every
"step" round. Thus if you choose step=10, then you
will be notified about every tenth round. On your first
run there will be more than 200 rounds, thus you don't
want your step to be too small.
Now use gdb to find out the first card in your hand.
Your assignment for this lab will consist of writing 2 functions that
are defined in the file game.c.
-
Write a function to calculate a number of cards in a hand.
Right now this function always returns 0. After your
function is written and debugged, prepare a typescipt
that uses cat to display the game.c, make to show compilation
(do not forget to remove all .o files before running script), and runs
your program with step 20. This script must be submitted for grading.
-
Write a function that cheats by inserting the ace of diamonds in your
hand. Make sure that the none of neighboring cards is the ace of
diamonds. After your function is written and debugged, prepare a
typescipt that uses cat to display the game.c, make to show compilation
(do not forget to remove all .o files before running script), and runs
your program with step 10. This script must be submitted for grading.
Do not forget about good programming practices, adequate comments and
documentation for your functions. Everybody should be able to
understand what your have done and why.
Enjoy,
Irene
This page was created by Irene Gassko.
Last updated on October 7, 1996.