The code is structured around object-oriented principles with classes modeling the problem and its solutions. The NqState class represents the state of the N-Queen problem, storing the positions of the queens. The NQueenHillClimbing, NQueenSidewayMove, and NQueenSimulatedAnnealing classes implement different strategies to find the solution.
- NqState: Manages the positions of queens and generates neighboring states.
- NQueenHillClimbing: Implements the hill-climbing algorithm to maximize the negation of conflicts between queens.
- NQueenSidewayMove: Extends hill-climbing to include sideway moves, allowing movement across flat landscapes.
- NQueenSimulatedAnnealing: Uses simulated annealing to avoid local maxima by probabilistically accepting worse states.