Find solutions to n-Queens Constraint Satisfaction Problems via AC-3 and Backtracking search.
MVC pattern implemented in Golang:
- main.go
- Controller connecting the web (View) package with the game (Model) package
- web package
- Views generated with "html/template" and Material Design Lite
- game package
- Model consists of a Constraint Satisfaction Problem (CSP) with a slice of n queens and a map of constraints
- Each queen tracks its column, row, and valid domain assignments. It also stores a boolean,
moveable
, indicating whether the user has restricted its location.
- Each queen tracks its column, row, and valid domain assignments. It also stores a boolean,
- A Backtracking search is used to find solutions to the CSP
- The queen with the most constrained domain is selected for assignment by an MRV heuristic.
- AC-3 is used to maintain consistency and generate inferences.
- Solutions are returned to the controller as JSON for display.
- Model consists of a Constraint Satisfaction Problem (CSP) with a slice of n queens and a map of constraints
To Run:
- Download Go
cd
intogoqueens
project directory- Execute
go run main.go
- Browse to localhost:3000