Click here to Skip to main content
15,905,508 members
Home / Discussions / C#
   

C#

 
Questionplease i need the complation of 4 queen [modified] Pin
amrreko9-Apr-10 3:26
amrreko9-Apr-10 3:26 
AnswerRe: please i need the complation of 4 queen Pin
DaveAuld9-Apr-10 4:05
professionalDaveAuld9-Apr-10 4:05 
AnswerRe: please i need the complation of 4 queen Pin
Maximilien9-Apr-10 4:06
Maximilien9-Apr-10 4:06 
AnswerRe: please i need the complation of 4 queen Pin
Keith Barrow9-Apr-10 4:07
professionalKeith Barrow9-Apr-10 4:07 
GeneralRe: please i need the complation of 4 queen PinPopular
Ian Shlasko9-Apr-10 4:11
Ian Shlasko9-Apr-10 4:11 
GeneralRe: please i need the complation of 4 queen Pin
Keith Barrow9-Apr-10 4:15
professionalKeith Barrow9-Apr-10 4:15 
GeneralRe: please i need the complation of 4 queen PinPopular
Dalek Dave9-Apr-10 4:16
professionalDalek Dave9-Apr-10 4:16 
QuestionRe: please i need the complation of 4 queen code Pin
amrreko9-Apr-10 4:37
amrreko9-Apr-10 4:37 
class Node
    {

        public bool[,] state { set; get; }//1
        public Node parent { set; get; }//2
        public List<Node> childs { get; set; }//3
        //6
        public int level { get; set; }
        public int Hfunction()//4
        {
        int res=0;
            return res;
        }
        public void generate_child()//5
        {
            for (int i = 0; i < 4; i++)
            {
               //creat copy of an object then do castting
                bool[,] newstate = (bool[,])this.state.Clone();//8
                Node child = new Node();//7
                childs.Add(child);//add to list
                child.parent = this;//declare to parent
                child.level = this.level + 1;
                newstate[child.level, i] = true;//9
                child.state = newstate;
            }
        
        
        }
        //10
        public bool visited { get; set; }
        public Node GetBestChild()//11
        {

            int Min = int.MaxValue;//max value  12
            int min_index = -1;//out side range of index
            Node BestChild = null;//declare null value for bestchild node
            for (int i = 0; i < 4;i++ )
            {
                int CurrentValue = this.childs[i].Hfunction();
                if (CurrentValue < Min && this.childs[i].visited == false)
                {
                    BestChild = this.childs[min_index];//14
                    BestChild.visited = true;

                    Min = CurrentValue;//13
                    min_index = i;//13

                }


            }
         return BestChild;
        }}



<pre>
class BFS
{
public Node BfsProcess(Node root)
{
Node soultion = null;
if (root.Hfunction() == 4)
{

return root;
}
else {
root.generate_child();
Node bestchild =null;
while ((bestchild = root.GetBestChild()) != null)
{
soultion = BfsProcess(bestchild);

}
return soultion;
}

}

}
AnswerRe: please i need the complation of 4 queen code Pin
Pete O'Hanlon9-Apr-10 4:56
mvePete O'Hanlon9-Apr-10 4:56 
AnswerRe: please i need the complation of 4 queen Pin
Dalek Dave9-Apr-10 4:10
professionalDalek Dave9-Apr-10 4:10 
AnswerRe: please i need the complation of 4 queen PinPopular
R. Giskard Reventlov9-Apr-10 4:12
R. Giskard Reventlov9-Apr-10 4:12 
AnswerRe: please i need the complation of 4 queen PinPopular
Pete O'Hanlon9-Apr-10 4:17
mvePete O'Hanlon9-Apr-10 4:17 
GeneralRe: please i need the complation of 4 queen Pin
R. Giskard Reventlov9-Apr-10 4:26
R. Giskard Reventlov9-Apr-10 4:26 
AnswerRe: please i need the complation of 4 queen Pin
loyal ginger9-Apr-10 4:26
loyal ginger9-Apr-10 4:26 
GeneralRe: please i need the complation of 4 queen Pin
Keith Barrow9-Apr-10 4:36
professionalKeith Barrow9-Apr-10 4:36 
GeneralRe: please i need the complation of 4 queen Pin
Media2r9-Apr-10 5:05
Media2r9-Apr-10 5:05 
GeneralRe: please i need the complation of 4 queen Pin
Keith Barrow9-Apr-10 5:09
professionalKeith Barrow9-Apr-10 5:09 
GeneralRe: please i need the complation of 4 queen Pin
amrreko9-Apr-10 5:09
amrreko9-Apr-10 5:09 
GeneralRe: please i need the complation of 4 queen Pin
Keith Barrow9-Apr-10 5:14
professionalKeith Barrow9-Apr-10 5:14 
GeneralRe: please i need the complation of 4 queen Pin
PIEBALDconsult9-Apr-10 5:07
mvePIEBALDconsult9-Apr-10 5:07 
AnswerRe: please i need the complation of 4 queen Pin
Viral Upadhyay9-Apr-10 4:38
Viral Upadhyay9-Apr-10 4:38 
GeneralRe: please i need the complation of 4 queen Pin
amrreko9-Apr-10 5:38
amrreko9-Apr-10 5:38 
Questionserver extension interface concept Pin
dialer19-Apr-10 2:46
dialer19-Apr-10 2:46 
Questionreading from a file and retrieving contents Pin
Morgs Morgan9-Apr-10 2:09
Morgs Morgan9-Apr-10 2:09 
AnswerRe: reading from a file and retrieving contents Pin
J4amieC9-Apr-10 2:29
J4amieC9-Apr-10 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.