示例#1
0
        // Generate tasklist from a node list
        public Queue <string> generatetasklist(List <Modelisation.Node> l)
        {
            Queue <string> tasklist = new Queue <string>();

            if (l.Count != 0)
            {
                Modelisation.Node node = l[l.Count - 1];

                // While the node is not the root node, we add its lastaction to the tasklist
                while (node.getLastAction() != "nothing")
                {
                    tasklist.Enqueue(node.getLastAction());
                    node = node.getParent();
                }

                //tasklist.Enqueue(node.getLastAction());
            }

            return(tasklist);
        }
        private Queue <string> generateTasklist(Modelisation.Node ns, Modelisation.Node ng)
        {
            List <string> actions = new List <string>();

            while (ns.getLastAction() != "root")
            {
                actions.Insert(0, ns.getLastAction());
                ns = ns.getParent();
            }

            while (ng.getLastAction() != "goal")
            {
                actions.Add(ng.getLastAction());
                ng = ng.getParent();
            }


            Queue <string> queue = new Queue <string>(actions);

            return(queue);
        }
示例#3
0
        public Dictionary <string, Modelisation.Node> retrosuccession(Modelisation.Node currentNode)
        {
            Dictionary <string, Modelisation.Node> newStates = new Dictionary <string, Modelisation.Node>();

            Floor testingFloor = new Floor(currentNode.getState(), currentNode.getPathcost());


            if (currentNode.getLastAction() == "nothing")
            {
                Modelisation.Node newnode = new Modelisation.Node(
                    testingFloor.getState(),
                    testingFloor.getAspXY(),
                    currentNode.getDepth() + 1,
                    //currentNode.getPathcost() + entry.Value.getCost(),
                    testingFloor.account(),
                    false,
                    "nothing",
                    currentNode
                    );
                newStates.Add("nothing", newnode);
                return(newStates);
            }



            foreach (KeyValuePair <string, Action> entry in actions)
            {
                entry.Value.reverse(testingFloor, testingFloor.getAspXY());
                if (isArrayEqual(testingFloor.getState(), currentNode.getState()) && entry.Key != "nothing")
                {
                    testingFloor.reset();
                    continue;
                }
                Modelisation.Node newnode = new Modelisation.Node(
                    testingFloor.getState(),
                    testingFloor.getAspXY(),
                    currentNode.getDepth() + 1,
                    //currentNode.getPathcost() + entry.Value.getCost(),
                    testingFloor.account(),
                    false,
                    entry.Key,
                    currentNode
                    );

                newStates.Add(entry.Key, newnode);
                testingFloor.reset();
            }


            return(newStates);
        }