Eight Queens Problem
This project is a class library that solves the Eight Queens Problem using a flexible and extensible algorithm.
The goal is to place eight queens on an 8x8 chessboard so that no two queens threaten each other.
The solution applies the best OOP practices, SOLID principles, and suitable software design patterns to create clean, maintainable, and easily expandable code.
Key Aspects:
- Analyzing potential future changes like board size, number and type of pieces, movement patterns, and attack/defense mechanisms.
- Defining core components: the board, the pieces, and the solving engine.
- Implementing a flexible board structure with a 2D array of cells, each holding properties like occupancy status.
- Designing piece objects with attributes for name, display method, and movement capabilities.
- Creating a dynamic movement system that allows for customizable directions, steps, and movement types (e.g., step, jump).
- Developing methods for placing and removing pieces, with logic to verify conflicts and apply specific game rules or any rules.
- Building a core engine capable of placing pieces without conflicts, adaptable for various chess-like puzzles.
This approach enables easy additions of new pieces, boards, movement rules, and even new engines, with minimal code adjustments. The possibilities are endless:
- Support for exotic pieces and custom board shapes.
- Flexible rules for piece interactions, movements, and board constraints.
- Reusable class libraries applicable to games, simulations, and educational tools.
Read more...
Last updated: February 2025
See the working demo