Crate qsolve

Source
Expand description

A library for solving Queens puzzles

This library is designed to solve Queens puzzles, with a few key characteristics:

  • Human-understandable: Humans solve queens by iteratively eliminating and confirming squares. This library does the same process; it doesn’t use and do any sort of search-algorithms to try and find the solution from afar.
  • Speed: Within the bounds of the above, it tries to be as fast as possible. This means, for example, it uses bitfields rather than HashSets for efficient operations on small sets.

§Example

Basic usage of the library looks something like this:

// Parse a text file containing a Queens puzzle.
let queens_file = QueensFile::try_from_text_file(&PathBuf::from("games/linkedin-1-empty.txt"))?;

// Generate the initial solve state and print it.
let solve_state = SolveState::from(&queens_file);
println!("{}", solve_state);

// Generate the list of heuristics to use to solve the puzzle.
let heuristics = all_heuristics(solve_state.board);

// Solve the puzzle and print out the solution.
let solved = solve_iter(solve_state, SolveStrategy::Fast, &heuristics).last().unwrap().solve_state;
println!("{}", solved);

Modules§

board
Structs to represent Queens boards.
datastructure
Data structures for efficient manipuations of rows, cols, colors and coords.
file
Logic to represent an underlying file containing a Queens game.
heuristic
Heuristics used to solve the Queens game.
image
Image parsing logic to allow screenshots of Queens games to be used.
share
Logic to generate the share text for a solved puzzle.
solveiter
Iterators for moving through the process of solving a game.
solvestate
Structs to represent intermediate states of solving a Queens puzzle.
squarecolor
Representation of different square colors and associated display logic.