/N-Queen-Puzzle-Game

N-Queen Puzzle Game is a puzzle game based on the 8-Queen Puzzle/Problem. It is a game in which we can solve the N Queen Problem for a grid or a chessboard of size N * N.

Primary LanguageJavaScript

N-Queen Puzzle Game

N-Queen Puzzle Game is a game based on the 8-Queen Puzzle published by chess composer Max Bezzel in 1848. This 8-Queen Puzzle game is extended to N-Queen Puzzle by Franz Nauck, person who published the solution of 8-Queen Puzzle in 1850.

The basic idea behind the N-Queen problem is arranging N chess queens on a N x N chessboard in such a way that no two queens threaten one other; as a result, none of the two queens should share the same column, row, or diagonal. We will be using the concept backtracking for find the solution of the puzzle, through Get Help button. As well as, we can also solve the problem manually.

Features :

  • We can set the size of grid/chessboard (recommended to set maximum grid size of 29 X 29).
  • If we got stuck in while solving the puzzle, we can press Get Help button to view the solution of the puzzle.
  • We can also clear the grid or chessboard using Clear Grid button while solving the puzzle, whenever we have moved the wrong step or we want to give another try to solve the same puzzle.

Build With :

Install and Run :

  1. Download the code and extract the zip file.
  2. Open the folder and double on the file named as "index.html" .
  3. You will see the page asking for the size of the gros or chessboard. Enter the size and hit OK.
  4. A greed/chessboard will be created on the right handside of the screen with rule/instruction on how to play game on the left handside of the screen
  5. After reading the rules/instruction you can start solving the puzzle.

Instruction of Game :

  1. Enter the size of the grid in the pop-up that appeared. If not done Kindly refresh the page.
  2. The user must arrange chess queens on a N x N grid in such a manner so that no two queens threaten one other; as a result, no two queens must share the same row, column, or diagonal.
  3. Click on the given cell to mark where the Queen you want to place.
  4. If your want to clear the grid, just press "Clear Grid" button.
  5. If you want to see the solution, just press "Get Help" button.
  6. If you want to change the grid size, just click on the Reset Grid Size button and enter new size in the pop-up box and press OK.
  7. If you win a pop will appear saying you WON, else you can retry to solve the puzzle.

Screenshot :

  • Asking to enter grid size :
    Asking to enter grid size

  • Solving Puzzle :
    Solving Puzzle

  • Message after solving the puzzle :
    After winng the game

  • Using Get Help Button :
    Using Get Help Button