Search for notes by fellow students, in your own course and all over the country.

Browse our notes for titles which look like what you need, you can preview any of the notes via a sample of the contents. After you're happy these are the notes you're after simply pop them into your shopping cart.

My Basket

You have nothing in your shopping cart yet.

Title: Tic tac toe game design
Description: This notes discusses how the tic tac toe game is designed in c++ language.

Document Preview

Extracts from the notes are below, to see the PDF you'll receive please use the links above


The Four By Four Tic-Tac-Toe
Game Design
Jiyane Hlanganani (1490763), Software Development 1 project
School of Electrical and Information Engineering,
University of the Witwatersrand,
Johannesburg 2050,
South Africa

Abstract
The Tic-Tac-Toe game also known as the noughts and crosses game has been played for a very long time since
from the Roman Empire
...
This paper is about the
tic-tac-toe game having a four by four game grid
...
Certain algorithms were designed using flowcharts
and implemented in c++
...
It was found that the players could play with each other or play with the computer and obtain their
live scores and at the end of each game proving that the implemented algorithms were successful in solving the
problem
...


1

I
...
In this game players are
assigned pieces to move in a three by three grid,
where they take turns in placing them
...
The main objective of this
paper is to design and implement a computerized
version of a tic-tac-toe game of a four by four
grid
...
The
background based on noughts and crosses game is
discussed in this report
...
The flow chart and the
flow diagram explaining how the code should work
would be discussed
...

Recommendations for further work on tic-tac-toe
games would be made
...
BACKGROUND

the Minimax algorithm, the games statistic revelled
that the three by three grid noughts and crosses
game can be made unbeatable where the players
always obtain draws [4]
...
The opposing player also ensures that the
move to make will benefit in the highest score
possible
...
In the four by four tic-tac-toe game,
the players have as much possible moves to make
which reduces the possibilities of obtaining too
many consecutive draws than in the three by three
noughts and crosses
...
D ESIGN METHODOLOGY
The design of the tic-tac-toe game can vary according to the size of the game board and the conditions
in place for the player to obtain a point
...
The order can be diagonal, vertical
or horizontal
...
In designing
the four by four tic-tac-toe game, certain conditions
regarding how the game must be designed are as
follows:
• The game must be having a four by four grid
and only two players
• The score is obtained by only having three
noughts or crosses contiguous
...
This game
was designed to be played by two players, it can
be two people playing against each other or one
person playing against the computer
...
These
players take turns in placing their pieces in the grid
where there is an unoccupied space [3]
...
Assumptions and constraints
8 in appendix A to place their moves
...
assumptions are made:
• It is assumed that the game board is a perfect
If no one amongst the players manages to get three
four by four
...

the two players, noughts and crosses and the
game board
...
In the The game limitations are as follows:
three by three tic-tac-toe game the probability of
• The game board must be empty before the
players obtaining draws is much higher than that
game begins
in the four by four grid which is of interest in this
• The player is not allowed to make valid moves
paper
...


2










There are only sixteen possible moves
...

Only three consecutive pieces that can make a
point
...

The game must be designed for two players
On the implementation, functions and classes
must be used

Fig
...
Simulation Flow diagram

1) Game flow-chart: The flow chart serves as the
main guide for developing an appropriate solution
to a problem [7]
...
It
makes understanding of the source code simpler
of which is the reason why it is used in this
report
...
In the flow chart, there are
some instructions that have their own flow charts
separated from the main flow chart
...
On the game flow chart,
the choose whom to play with option also houses
the option of the players to enter their names
...
If the board is found
Inside the class, there are member functions used not full the player enters the move and it get stored
...
if the player entered an
insert their names, for players to enter their moves, existing or wrong move, the player is given another
for the computer to enter it moves, to convert chance to make another move
...
This vector
indexes, to check whether the game board is full is of choice because each correct player move can
and write the player moves as well as their scores be pushed to it once validated so that when another
to file and display the history of all the games move is made is first checked whether it exist in this
played
...
When the player makes the
known, the board would be implemented using correct move, it is then place in a board and the
an array having four rows and four columns [6]
...
The flow chart in figure 7 in
The flow diagram in figure 1 shows the summary appendix A shows the algorithm behind switching
of merger components involved in designing the of the players
...
In the in the game board
...
The results
elaborated to give a clear overview of how they from a full board would then indicate that the game
work together to develop the full tic-tac-toe game is over and the score of players must be printed
...

and determine the winner is showed in figure 6 in
B
...
This concept
enables re-usability and maintainability of the
code [5]
...

The reason of having one class in this game is
that, it is much easier to debug and manage it
public as well as private members [3]
...
These member
functions have their own specific task which are
then combined to get the desired outcomes
...


3

If the player decides to change the name, the
player would be indicating to change the opponent
therefore the loop for choosing whom to play with
is called so that the player can choose whether
the next game must be a single player (playing
with the computer) or two players game
...
The outer
if statement checks whether the move made is
already been stored in a vector or not and return a
Boolean result
...
Figure 8 in appendix A shows the
format of the coordinates the player is restricted
to excluding the cells that are coloured with a red
colour
...
2
...

IV
...

The game class is implemented with it private as
well as it public member variables and functions
responsible for the whole implementation
...

The inner while loop is responsible for allowing
players to play, print the game board after each
move and show the game live score till the game
board is full
...
It also enables
players to change names and their opponents
...


The output game score statement in the main flow
chart in figure 2 for getting the players scores is
implemented using multiple if statements and for
loops
...
The reason this
implementation was of choice is that although
it time complexity is large, it is guaranteed that
the correct score would be obtained
...
This methodology is used in
multiple game designs such as in creating simple
text-based games book [3]
...
The
decimal number that the computer generate is then
converted to correct board coordinates and place in
a board
...
The
following is the pseudo-code to emphases the
implementation of the noughts and crosses game in
c++
...


4

Declare variables and functions;
choose game mode; players enter names;
while(play choose to play tic-tac-toe){
while(space is available in the board){
player enter move;
if(player move is correct){
if(move not found in a vector){
place move in the game board;
store move in the vector;
get player current score;
}else{print space already taken, enter again}
}else{print invalid move, enter again;}
if(space is not available){
if(player1 score > player2 score){
print player is a winner;
}else if(player1 score == player2
score){print that game is tie;}
else{print player2 is a winner;}
}
}
is player choosing a re-match?
if(answer is yes){is player changing a name?
if(answer is yes){set player name; play
game} continue game} else{print game exit}
} {close the main loop}

include artificial intelligence
...
The
reason of such a computer response relies on the
range of the numbers to be generated
...

The computer randomly places a move anywhere
in the board without checking for an available
point to score or for an available space to block
an opponent
...
The graph revealed that the random
placement algorithm was not an efficient algorithm
to be implemented for a computer since it can
be guaranteed that the computer will always be
defeated [9]
...
From the
graph in figure 4, it was noted that the possibility
of obtaining a score greater than or equal to four is
very rare between the two players
...

In comparison with the single player game mode,
V
...
The game simulation was all players are aiming to get the point by placing
run multiple times
...

players could choose whether they want to continue
play or exit the game, they were given the chance to
enter their preferred names to use
...
The game
live score was obtained each time the player enters
the move
...
The player was given the chance to
view games history
...

1) Analysis and evaluation of results: After the
first eleven matches in a single player game mode,
it was obtained that when the game is not a tie the Fig
...
Computer and player scores comparison
player will always defeat the computer
...
This happens when the
first player from the very first three moves try to
make a point
...
While
the second player is blocking the moves made by
the first player, the moves of the second player
somehow form its own combinations to make a
point
...
This feature links to the
Minimax algorithm mentioned in section II [4]
...

VII
...
This is due to certain criteria
listed in section III that were accomplished
...
The score of each player
was obtained every time the player makes a valid
move
...

At the end of each game, the players were given the
chance to re-match the game
...
Relevant data structures to implement this
game in further tic-tac-toe game design were also
recommended
...
4
...
R ECOMMENDATIONS
The noughts and crosses game can be implemented
using other data structures such as trees and linked
lists [9]
...
The
sequence of branches in a tree could help in tracing
the winning moves [10]
...

Having more than one class is recommended
since it helps in breaking the game implementation
into smaller manageable bits which could improve
the understand of the game code [8]
...
Golomb, Alfred W
...
Hypercube Tic-TacToe
...
California : MSRI
Publications, 2002
...
0-609-04316-3
...
Boston : Cengage learning , 2010
...

[4] Fox Jason
...
Baltimore : Never Stop Building , 2013
...

New York : Prentice-Hall International, Inc, 1994
...

New York :
McGraw-Hill, Inc
...

[7] Anil Bikas Chaudhuri, THe Art of Programming Through
Flowcharts and Algorithms, 3rd ed
...
Ltd
...

[8] Mark Lee, C++ Programming for the Absolute Bebinners,
2rd ed
...

[9] Michael T
...
London, United States of
America: John Wiley and Sons, Inc
...

[10] M
...
Carberry, Foundations of Computer Science, 3rd ed
...
I NTRODUCTION TO APPENDIXES
This section of this paper is about relevant information discusses in the above subsections and also
introduces the new important content which is the project time management in appendix B
...
In the time
management, the project is broken down to smaller sub-sections and each sub-section is allocated it own
time frame
...
The time management planning is elaborated in appendix B of this report
...
5
...
6
...
8
...
7
...
P ROJECT T IME M ANAGEMENT
This section discusses the report planning process with regards to time management
...
Each task was then given it own time frame
...

TABLE I
T HE TABLE SHOWING THE PROJECT TASKS AND THEIR ALLOCATED TIME FRAMES
Time management
Tasks

Allocated
hours

Background (problem
understanding)

10

Analyses and design

15

Implementation

15

Testing and debugging

10

Documentation

10

Time

in

c

Table I shows the preliminary time schedule for each component of the project
...
This was due to many hours spent on
the implementation, testing and debugging
...

TABLE II
T HE TABLE SHOWING THE TOTAL NUMBER OF TIME IN HOURS SPENT IN THE PROJECT
Time management
Tasks

Exact time spent in
hours

Background (problem
understanding)

10

Analyses and design

15

Implementation

18

Testing and debugging

14

Documentation

10

Total hours

67 hours

The graph in figure 9 compares the exact time spent in the project with the assumed time
...


Fig
...
Two player mode scores comparison

3
...

Although the more time spent during project implementation and testing increase, the project objectives
were accomplished
...
This could lead to successful completion of the
project without anytime added
Title: Tic tac toe game design
Description: This notes discusses how the tic tac toe game is designed in c++ language.