The Challenge of N Queens

The N Queens puzzle asks: How can you place N queens on an N×N chessboard without any two queens threatening each other? With 4,426,165,368 possible arrangements for eight queens, finding the 92 valid solutions is no small feat.

Hopfield Networks: A Neural Approach

Our solution leverages Hopfield networks, a type of recurrent artificial neural network. These networks evolve towards certain predefined patterns by minimizing total network energy, similar to reducing system noise.

Implementing the Solution

Rather than storing patterns, we encoded the puzzle's constraints into the network's synaptic connections. Each neuron has four synapses to implement constraints between queens. To overcome local minima issues, we incorporated Simulated Annealing, a hill-climbing search method that introduces stochastic elements.

Visualization with Pygame

The graphical interface, built using Pygame, allows real-time viewing of the algorithm's progress. Python's "yield" keyword enables updates without returning, creating an engaging visual experience.