Algorithm solves the problem of the chess pieces placement on a chess board in a way they can't capture each other. This is a kind very well known puzzle Eight queens but with other chess pieces involved.
The main idea of this algorithm is to try every possible combination of calculated pieces places until the correct answer(s) is found. We focus on finding the number of possible placements. This is a recursive algorithm with backtracking approach.
Algorithm works like demonstrated below, but additional chess pieces available.
- Java single-thread approach - uses recursive backtracking algorithm
- Java implementation has a console output which indicates the number of possible combinations and the placement of figures in each found solution
Simple (using queens() method inside Main.java file)
- Figures
- Queens 8
- ChessBoard 8x8
- Results: 92
- Elapsed time (ms): 840
Complex (using complex() method inside Main.java file)
- Figures
- Black King
- Black Queen
- Black Rock
- Black Knight
- Black Bishop
- White King
- ChessBoard [9x6]
- Results: 20136752
- Elapsed time (ms): 30800
Machine: Intel Core i7, 2.0Ghz, 16GB RAM