Exemplo n.º 1
0
        //Trebuie modificata
        private void AddSuccessors(SearchTreeNode currentNode)
        {
            SearchTreeNode left, right, up, down;
            int            i = 0;

            while ((i < n * n) && (DecodeState(currentNode.GetState())[i] != 0))
            {
                i++;
            }
            if ((i / n) != 0)
            {
                up = new SearchTreeNode(currentNode, EncodeState(GenerateState(DecodeState(currentNode.GetState()), i, 1, 0, 0, 0)), currentNode.GetDepth() + 1);
                nodesToExplore.Enqueue(up);
            }
            if ((i / 3) != 2)
            //nu este pe linia de jos deci se poate muta jos
            {
                down = new SearchTreeNode(currentNode, EncodeState(GenerateState(DecodeState(currentNode.GetState()), i, 0, 1, 0, 0)), currentNode.GetDepth() + 1);
                nodesToExplore.Enqueue(down);
            }
            if ((i % 3) != 0)
            //nu este pe coloana din stanga deci se poate muta stanga
            {
                left = new SearchTreeNode(currentNode, EncodeState(GenerateState(DecodeState(currentNode.GetState()), i, 0, 0, 1, 0)), currentNode.GetDepth() + 1);
                nodesToExplore.Enqueue(left);
            }
            if ((i % 3) != 2)
            //nu este pe coloana din dreapta deci se poate muta

            {
                right = new SearchTreeNode(currentNode, EncodeState(GenerateState(DecodeState(currentNode.GetState()), i, 0, 0, 0, 1)), currentNode.GetDepth() + 1);
                nodesToExplore.Enqueue(right);
            }
        }
Exemplo n.º 2
0
 public SearchTreeNode(SearchTreeNode pn, int s, int d)
 {
     parrentNode = pn;
     state       = s;
     depth       = d;
     //  n = _n;
 }