Chess Game Project using HTML & Java Script

The objective of the project:

The objective of our Online Chess Game project is to create an online Chess game that enables you to both play with your friends as well as against the computer.

Chess Game Rules:

  • The player with white pieces starts his turn first.
  • The Player has to protect his king and subsequently make strategies to kill the opponent’s king.
  • When the king of one player is checked by the other player’s pieces, he will have to take the king out of that check to a safe place. The player who checks the king has to warn the opponent by saying “CHECK”.
  • The one to lose his king will be the one to lose the game.

Features:

Player vs Computer:

The player will have to start with whites and make her first move, and the computer will take blacks.

Player vs Player:

The player who takes whites should start first and the other player plays alternately.

Main Functions in Player vs Computer code:

1 updateSquarecolor()
This function is used to update the colors of each square after each move.
2 checkBlack(n,values)
This function is used to find all the possible places where a selected white chess piece can be moved in this step.
3 checkWhite(n,values)
This function is used to find all the possible places where a selected black chess piece can be moved in this step.
4 checkmate()
This function is used to check if there would be a danger to your king if you make any move and declares you to have lost.
5 check()
This function is used to make your moves, if possible, and also to warn the player if the king is in check and the player is not trying to protect it, by the use of the checkBlack and check white functions described above.
6 chooseTurn()
This function is helpful for the computer to play its move by moving forward with the best possible move. It also declares the player as a winner if there is no possible move for the computer to make while protecting its king. It basically
helps in the propagation of the game step by step.
7 startTime()
This function is to show the current time and day.
8 maxxTime()
This function is used to check the time limit for each move and warn the player after 45 seconds and stop the game and declare him to have lost after 1 minute.
9 maxxTime2()
This function is used to check and stop the game at a maximum time limit of 45 minutes and the game would be declared drawn.
10 restart()
This function is used to restart the timer after each move.

Main functions in Player vs Player code:

1 updateSquarecolor()
This function is used to update the colors of each square after each move.
2 checkBlack(n,values)
This function is used to find all the possible places where a selected white chess piece can be moved in this step.
3 checkWhite(n,values)
This function is used to find all the possible places where a selected black chess piece can be moved in this step.
4 checkmate()
This function is used to check if there would be a danger to one’s king if they make any move and declares him to have lost.
5 check()
This function is used to make your moves, if possible, and also to warn the player if the king is in check and the player is not trying to protect it, by the use of the checkBlack and check white functions described above.
6 startTime()
This function is to show the current time and day.
7 maxxTime()
This function is used to check the time limit for each move and warn the player after 45 seconds and stop the game and declare him to have lost after 1 minute.
8 maxxTime2()
This function is used to check and stop the game at a maximum time limit of 45 minutes and the game would be declared drawn.
9 restart()
This function is used to restart the timer after each move.

Installation:

Download all our files and put them collectively in a folder named “Chess”.

In Ubuntu:

Now put this folder into the /var/www/HTML/ folder in the other locations on your computer.

In Window:

Download XAMPP on your PC and put this folder into the htdocs folder of XAMPP.
Now go to your web browser and type localhost/Chess/
Best viewed in Google Chrome and Mozilla.
Download the Chess Game HTML project Code & Report

Leave a Reply

Your email address will not be published. Required fields are marked *