This is the final report showing all the work put into Mark Smith and Trevor Snaith's noughts and crosses program, for this semesters work. The report includes the aims throughout the project, which is to produce a noughts and crosses programme in "C", the problems which we encountered during writing the program and how we solved them. It shows the results of our noughts and crosses program including some printout from the program and an explanation of how the programme works. It also shows some improvements on how the programme could be made better, and a conclusion.
Aims
To develop a "C" program that allows two people to play "noughts and crosses. The computer must decide when the game has been won and by whom, or whether the game has been drawn. The computer should display the board after each move.
Results
When the programme is first run the opening screen appears as below:-
This opening screen is put together using a series of "printf" functions. It asks the user if they wish to play, if the user decides to play they key in number one. The one is stored as an integer in a box called "play". Using an if statement, if play is equal to one then this follows:-
Once the one is pressed then the rules appear and using a printf statement to bring up "Player 1 (x) please enter your first name", Mark the first player then enters his name which is stored using a scanf statement. Once his name has been entered and the carriage return button is pressed then "Player 2 (o) please enter your first name" appears. Trevor the second player enters his name, which is also stored as a scanf statement. Once the carriage return is pressed the following appears:-
"Mark will go first" appears using a printf statement. Before the board appears the computer checks using a while statement to see if there is a win for "x - Mark", "0 - Trevor" or a draw, if none of these statements are true then the board is displayed and "Mark please enter a row number and press enter"