Skip to content

Instantly share code, notes, and snippets.

@mark-d-holmberg
Created September 7, 2011 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mark-d-holmberg/1201636 to your computer and use it in GitHub Desktop.
Save mark-d-holmberg/1201636 to your computer and use it in GitHub Desktop.
Eight Queens as a List Help (Prolog)
Mark Holmberg, Dixie State College of Utah
CS 3520, Programming Languages
7 Sept. 2011
Some help with 8-queens so you don't have to type as much.
If you want to test your 8-Queens predicate you can NOT write a test predicate
like Russ said. Although it does work, it only returns true or false NOT the
list of the proper queen locations. The following is the test case I used.
eight_queens( [Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8] ).
If your test is successful you should get output like this:
Q1 = 1,
Q2 = 5,
Q3 = 8,
Q4 = 6,
Q5 = 3,
Q6 = 7,
Q7 = 2,
Q8 = 4 .
You can type ; to get more solutions.
Best of luck.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment