Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Solves the NQueens problem using Uniform Cost Search or A* Search

License

NotificationsYou must be signed in to change notification settings

MManoah/NQueens-OptimalPathAlg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The N-queens puzzle is the problem of placing N queens on an N x N chessboard such that no two queens attack each other. This finds a solution to an N-Queens problem using either Uniform-Cost search or A* search.

The indexes of the list will represent columns on a chessboard (0 -> N-1) while the numbers in each index will represent the row of the queen location in that column (0 -> N-1).

The Two Algorithms

A*

The A* algorithm uses a combination of heuristic values and the path cost in order to find an optimal solution. This algorithm is significantly faster than Uniform-Cost.

f(n) = g(n) + h(n) where:

g(n) = path cost

h(n) = heuristic (estimated cost to the goal)

Uniform-Cost

The Uniform-Cost algorithm uses the path cost in order to find an optimal solution.

f(n) = g(n) where:

g(n) = path cost

Example

Here is a solution for the 8-Queens problem using the two algorithms

Here would be the board configuration for A*

Built With

  • Python

License

This project is licensed under the MIT License - see theLICENSE file for details

About

Solves the NQueens problem using Uniform Cost Search or A* Search

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp