jeffpanici75 / n-queens

An N queens solver written in Java that also detects at least three queens which are collinear, e.g. "three in a line"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

N Queens and No-three-in-line Solver

This program implements a binary, symmetry aware, backtracking solution to the N Queens problem. The algorithm is based primarily on the work in the paper, "Backtracking Algorithms in MCPL using Bit Patterns and Recursion," by Martin Richards. Code was added to detect mirror image solutions. The paper discussions a recursive algorithm, but this program implements the solution as an iterative state machine to limit call stack depth.

In addition, the solver checks for any three queens which are collinear. The visualizer marks collinear paths as red, and all other paths as green. This part of the algorithm was based on the, "No-three-in-line problem," which is discussed here.

The visualizer allows the user to filter the results based on detection of collinear queens.

Screenshots

Working with the code

I use IntelliJ as my IDE, but the code should work in Eclipse. Gradle is the build system.

The code is built against and requires Java 13 to run. I make use of preview features in the Java language, so the --enable-preview is required for compiling and running.

About

An N queens solver written in Java that also detects at least three queens which are collinear, e.g. "three in a line"

License:MIT License


Languages

Language:Java 100.0%