Skip to content

Low-level design of Tic tac toe game in Javascript with oops concept for machine coding practices

Notifications You must be signed in to change notification settings

codeShaurya/tic-tac-toe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic-Tac-Toe

Problem Statement

Let's look at the game of Tic Tac Toe. Tic Tac Toe is a two-player strategy game played on a 3*3 grid. There are 9 empty cells and 9 pieces - 5 pieces of 'X' and 4 pieces of 'O'

The game starts with an empty grid.

Rules of the game The game is played between two players. One player owns the X pieces and can put it on any of the empty cells in the grid. The other player owns the O pieces and can in any of the empty cells. The player with X makes the first turn. Each player plays alternately after that. The first player to form a horizontal/vertical/diagonal sequence wins. Requirements Create a command-line application for tic tac toe with the following requirements:

Ask the user for the names of the two players Print the grid after initializing Allow the user to make moves on behalf of both the players. The user will make a move by entering the cell position. You need to determine the piece (X/O) and make the move if it is valid. Valid move: The piece is controlled by the player having the current turn The cell is empty If the move is invalid print 'Invalid Move' the same player plays again If the move is valid: put the piece on the cell print the board after the move Determine if a player has won or if there are no valid moves left. Ignore all moves mentioned after that. A position in the cell is represented by two values: row number (1-3) and column number (1-3).

Detail problem statement can be read at: https://workat.tech/machine-coding/practice/design-tic-tac-toe-smyfi9x064ry

Solution

Javascript is used with all OOPs concent in design of the solution

Game Board

About

Low-level design of Tic tac toe game in Javascript with oops concept for machine coding practices

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published