This is a C++ console-based game based on the N-Queens problem, where the player must place queens on an N ร N chessboard without any queen attacking another. The game ends immediately if a queen is placed in an attackable position.
- Run the program and enter the board size
N. - Enter queen positions in the format:
row column(0-based index). - Type
helpto highlight all attackable positions on the board. - The game ends if a queen is placed in an attackable position.
โ
Custom Board Size - Choose any value for N.
โ
Live Attack Zone Highlighting - Type help to see under-attack positions (X).
โ
Chessboard Formatting - Row and column numbers improve readability.
โ
Instant Game Over - Placing a queen under attack ends the game immediately.
- Clone the repository:
git clone https://github.com/your-username/NQueensGame.git cd NQueensGame - Compile the program:
g++ -o nqueens nqueens.cpp
- Run the game:
./nqueens
NQueensGameclass handles board mechanics and user input.printBoard()displays the chessboard with proper formatting.isUnderAttack()checks if a position is under attack.play()runs the game loop and takes user input.
Enter board size (N): 5
Enter position: 2 3
0 1 2 3 4
---------------
0| . . . . .
1| . . . . .
2| . . . Q .
3| . . . . .
4| . . . . .
Feel free to submit issues or pull requests to improve the game! ๐
This project is licensed under the MIT License. See LICENSE for details.