| This article is specially dedicated for those
with interest in artificial intelligence subject. The main topic
is N Queen Problem, a classical problem of constraint satisfaction.
However, this problem will always great to be discussed all the
time. If you are a beginner in this section, please read the preface
on the left side of this page.
I have made many versions of code in some different programming
languages. Here is one of them, written in C++, compiled using Turbo
C++ 1.0 from Borland. The running time is not really short, but
this code has a very good N-Time curve where it is smooth and clean
from exceptions and errors. Soon, I will publish my newer and better
codes here, too. Please be patient.
You can download, compile, analyze and change any part of the source
code below. If you find out how to make this algorythm works better,
please send me an e-mail containing the change you have made and
some explanations about your new improvements.
The code is very simple. It uses one 1-dimension array called "boleh"
that is refreshed in every backtracking. The refresh function is
called "generate_sah()". The final solution is stored
in array "jawab". This code is able to generate first
or all solutions for N Queen problem where the value of N can be
4 to 1000. I have never try to find any solution of 1000 queens
using this program. Why ? Because it will take too much time ( but
my program is able to do that ! ).
Any comments, questions, or suggestions can be sent to robertsetiadi@gmail.com.
Related links :
N Queen Problem (2) by Daniel
Handoko
|