Title: Dancing Links and N k Queens Funded by: Kentucky NSF EPSCoR: UKRF 304688440007419
1Dancing Links and N k QueensFunded by
Kentucky NSF EPSCoR UKRF 3046884400-07-419
John Miller (millerj10_at_nku.edu) Dr. Doug
Chatham Dr. Maureen Doyle Dr. Jeffrey Ward Amber
Rogers Luke Thompson
2Agenda
- N Queens Problem
- Dancing Links
- N k Queens Problem
- Finding Solutions
- Results
- Future Work
3The N Queens Problem
- First proposed by Max Bezzel in 1848 as the 8
Queens Problem. - The problem has been investigated by
mathematicians since its inception, including
Gauss and Cantor - After solutions were found in 1850 by Franz Nauk,
it was expanded to the N Queens Problem
4The N Queens Problem
- How many ways can n Queens on an n x n chessboard
so that no queen can attack another queen - Commonly used to introduce recursion
5What are Dancing Links?
- Dancing Links is a data structure that can be
used to help solve any full cover problem. - N k Queens
- Sudoku
- Introduced in 1979 by Hitotumatu and Noshita .
- Popularized by Knuth in 2000
6The Dancing Links Universe
Things get complicated very quickly For an n x n
chessboard, the universe will have 6n-2 columns
and 4n26n-1 nodes
7The Dance Steps
solve( int x ) if ( x n) solution found
return choose a row r for placing
queen remove row r for every block b in row
r place queen on block b remove bs
column remove bs diagonals solve(x1) repla
ce bs diagonals replace bs
column replace row r
8Results
- N Queens Standard Backtracking vs. Dancing
- Links (DLX)
9N k Queens Problem
- Consider a chessboard where we have blocked k
squares. This is equivalent to placing a pawn on
this square. The pawns are unable to attack by
default.
This problem was first proposed in 1995 by
Michael Anshel.
10N k Queens Problem
- We have shown that there exist integers n and k
such that we can safely place nk queens and k
pawns on an n x n chessboard - For each positive integer k and N gt max87 k,
25k - Also, no more than n k queens can safely be
placed on an n x n chessboard with k pawns.
11Approach to Solving N k Queens
- How do we take advantage of the universe with the
pawns. - Look at all pawn positions and split the
universe. - Can we mimic the process of removing and
replacing portions of the universe?
12Splitting Pawns
- Before finding Solutions, we must split the
universe based on the positions of the pawns
Given a block b to place a pawn Create a new
header block Move everything below b into the
group Remove b from its group
13Splitting Pawns
Before Split
After Split
Head
Head
New Head
X
X
Y
Pawn
Pawn
Y
Notice Pawn has nothing pointing to it, but It is
still pointing to its former up and down nodes
14Reducing Search Space
- We have shown the following
- In order to place n k queens and k pawns on an
n x n board - No two pawns may share an edge
- No pawn may be placed on the outer edge of the
board - No pawn may be positioned on a square adjacent to
a corner square.
15How fast is it on n k Queens?
Results obtained on Dual Core 64-bit Athlon
Processor, running red hat v4
16How Fast is it? (cont.)
- For some small values of n and k, the cost of
creating the universe outweighs the benefit. - For large value of and k, the speedup of DLX is
invaluable.
17Parallel Results
- Approach to implementing with MPI
Current results indicate a 30 speedup on a 16
node cluster We are investigating other
approaches to achieve a More appropriate speedup
18Whats Next?
- Logic Programming
- Learning when we reach a dead end
- 3D Queens
- Can the DLX universe be extended to a 3D full
cover problem - Theoretical Chess Pieces
- Extending movement beyond straight lines
19References
1 CHATHAM, R. D., DOYLE, M, FRICKE, G.H.,
SKAGGS, R.D., AND WOLFF, M. Separating queens
on the chessboard 2 KNUTH D.E. Dancing links.
Millennial Perspectives in Computer Science.