Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
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 
i will explain simply

make a program to solve 4 queen problem that by using two classes
Bfs class that contains breadth first search
and Node class contains Best node to choose
take that my work in section

http://www.mediafire.com/?zkzhlenykj3[^]


picture explain
http://www.mediafire.com/?txky0xkdngq[^]
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;
        }

    }

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;
        }

    }

}

you can find nice solve but must use bfs
i find smart project like http://www.mediafire.com/?txky0xkdngq[^]
but i need to do simple project 4x4 board
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 
GeneralRe: reading from a file and retrieving contents Pin
Morgs Morgan9-Apr-10 3:10
Morgs Morgan9-Apr-10 3:10 
AnswerRe: reading from a file and retrieving contents Pin
OriginalGriff9-Apr-10 2:30
mveOriginalGriff9-Apr-10 2:30 
GeneralRe: reading from a file and retrieving contents Pin
Morgs Morgan9-Apr-10 3:32
Morgs Morgan9-Apr-10 3:32 
QuestionA reference to 'mscorlib' cannot be added Pin
sekannak9-Apr-10 2:00
sekannak9-Apr-10 2:00 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
Luc Pattyn9-Apr-10 2:06
sitebuilderLuc Pattyn9-Apr-10 2:06 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
Morgs Morgan9-Apr-10 2:13
Morgs Morgan9-Apr-10 2:13 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
harold aptroot9-Apr-10 2:28
harold aptroot9-Apr-10 2:28 
GeneralMessage Removed Pin
9-Apr-10 2:31
sekannak9-Apr-10 2:31 
GeneralRe: A reference to 'mscorlib' cannot be added Pin
harold aptroot9-Apr-10 2:34
harold aptroot9-Apr-10 2:34 
RantRe: A reference to 'mscorlib' cannot be added Pin
harold aptroot9-Apr-10 3:30
harold aptroot9-Apr-10 3:30 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
sekannak9-Apr-10 2:33
sekannak9-Apr-10 2:33 
GeneralRe: A reference to 'mscorlib' cannot be added Pin
Dave Kreskowiak9-Apr-10 3:19
mveDave Kreskowiak9-Apr-10 3:19 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
Luc Pattyn9-Apr-10 2:36
sitebuilderLuc Pattyn9-Apr-10 2:36 
AnswerRe: A reference to 'mscorlib' cannot be added Pin
PIEBALDconsult9-Apr-10 4:41
mvePIEBALDconsult9-Apr-10 4:41 

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.