Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
Hi there,
I am trying all the week, to find a solution of n-queens problem using forward checking algorithm, there are a lot of examples in google with depth first or breadth first but no with forward checking.

Please if u have any solution with forward checking, can u help me ???

p.s

no 8-queens but n-queens
Posted
Comments
Christian Graus 16-Dec-12 15:49pm    
Given that this is your homework, you should post what you've tried to do and ask a SPECIFIC question. Finding source code to copy on the web, is not doing your homework, or learning
h5h6 16-Dec-12 16:34pm    
In fact it is homework, I am telling u the truth.
I find a lot of source code for 8 queens but not with forwad checking they are with breadth first algorithem.... I need with FC ?
Jibesh 16-Dec-12 19:46pm    
we dont do your homework. get the source for 8 queens and try yourself to work with n-queen and still you find trouble with the code we are here to help.

hope it wont be tough as you think. give a try and comeback. Good Luck.
[no name] 16-Dec-12 23:03pm    
You might have heard that joke :
Google + Wikipedia(or any other site) + Ctrl+c + Ctrl+V = HOMEWORK DONE
h5h6 17-Dec-12 2:54am    
the only problem is that I don't understand how to implement the code, i now how work Depth First, Bredth first, forward checking. But to implement in code i don't now where to begin ?
e.x
this code here:
public bool IsAttacking(Queen q)
{
if (this.row == q.row || this.column == q.column) return true;
if (Math.Abs(this.row-q.row) == Math.Abs(this.column-q.column)) return true;
return false;
}
Is it depth first or FC ?

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
 
Share this answer
 
Comments
h5h6 17-Dec-12 2:55am    
the only problem is that I don't understand how to implement the code, i now how work Depth First, Bredth first, forward checking. But to implement in code i don't now where to begin ?
e.x
this code here:
public bool IsAttacking(Queen q)
{
if (this.row == q.row || this.column == q.column) return true;
if (Math.Abs(this.row-q.row) == Math.Abs(this.column-q.column)) return true;
return false;
}
Is it depth first or FC ?
OriginalGriff 17-Dec-12 3:06am    
If you don't understand how to implement it, then you need to read up on the algorithm again.
When you understand the algorithm, the implementation should just fall into place - it's just a code job.
h5h6 17-Dec-12 4:11am    
I think I have done something good, so I need know just one explaining.
if (rbtDFS.Checked)
{
s = (State)lbStates.Items[lbStates.Items.Count - 1];
lbStates.Items.RemoveAt(lbStates.Items.Count - 1);
}
else
if(rbtBFS.Checked)
{
s = (State)lbStates.Items[0];
lbStates.Items.RemoveAt(0);
}
this is a code so based on work to DFS and BFS I will try to write code for FC
but can you explain ne shortly the code:
s = (State)lbStates.Items[lbStates.Items.Count - 1];
lbStates.Items.RemoveAt(lbStates.Items.Count - 1); FOR DFS?

and
s = (State)lbStates.Items[0];
lbStates.Items.RemoveAt(0); FOR BFS ??

THNX A LOT!
h5h6 20-Dec-12 10:50am    
do u have any ide for forward checking algorithm ?? in c#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900