Git Product home page Git Product logo

dlx-and-8-queens's Introduction

DLX and 8 Queens

Try it!

I'm trying to animate Dancing Links by Donald Knuth, using the Eight Queens Puzzle

The clever choice of options ordering is too smart in QUEENS-DLX by Knuth. No backtracking occurs below n=16. I decided to start with a naive order. Now backtracking happens a lot even for n=8.

Primary items (8+8)

Mandatory. All rows and all columns must be covered exactly once

  • RA..RH rows (8)
  • CA..CH columns (8)

Secondary items (15+15)

Not mandatory. Diagonals can be covered at most once

  • AA..AO left diagonals (15)
  • BA..BO right diagonals (15)

The four corner diagonals, AA, AO, BA and BO have only one option, so they are actually not needed. No risk for two queens on these.

Options (8 x 8 = 64)

  • a1..h1 first row, RA
  • a8..h8 last row, RH
  • a1..a8 first column, CA
  • h1..h8 last column, CH
  • a1..a1 first left diagonal, AA
  • h8..h8 last left diagonal, AO
  • a8..a8 first right diagonal, BA
  • h1..h1 last right diagonal, BO

Target

When all queens are placed on the board and in legal positions, the first solution has been found. This viewer only shows the first solution.

Mouse

  • Texts in yellow are mouse aware
  • Hold the mouse over item names, e.g. CA
  • Hold the mouse over a chess square, e.g. a1
  • Click on one of the snapshots in the list to the right

Keyboard

  • Down Arrow: go to next snapshot
  • Up Arrow: go to previous snapshot
  • Space: Compact or Expanded View

Snapshots

8queens.json is generated by 037-DLX. Simplified extract:

options: "a1 a2 a3 a4 a5 a6 a7 a8 b1 b2 b3 b4 b5 b6 b7 b8 c1 c2 c3 c4 c5 c6 c7 c8 d1 d2 d3 d4 d5 d6 d7 d8 e1 e2 e3 e4 e5 e6 e7 e8 f1 f2 f3 f4 f5 f6 f7 f8 g1 g2 g3 g4 g5 g6 g7 g8 h1 h2 h3 h4 h5 h6 h7 h8"
items: "CA CB CC CD CE CF CG CH R1 R2 R3 R4 R5 R6 R7 R8 AA AB AC AD AE AF AG AH AI AJ AK AL AM AN AO BA BB BC BD BE BF BG BH BI BJ BK BL BM BN BO"
snapshots: 
  choices: "" entries: {...}
  choices: "a1" entries: {...}
  choices: "a1 b3" entries: {...}
  choices: "a1 b3 c5" entries: {AE:"d2" AF:"e2" AH:"e4 g2" AI:"f4 h2" ...}
  ...

Related links

dlx-and-8-queens's People

Contributors

christernilsson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.