Ejemplo n.º 1
0
        public void Initialize()
        {
            strategyMgr = new StrategyManager();
            grantTrees  = new GeneratedGrantTrees();
            Settings settings = new Settings();

            searchNodes   = new SearchNodes(strategyMgr, grantTrees, treeOperation);
            treeOperation = new TreeOperation(strategyMgr, grantTrees);
            strategyMgr.setSpecifiedTree(settings.getPossibleTrees()[0].className);
            strategyMgr.setSpecifiedEventStrategy(settings.getPossibleEventManager()[0].className);
            strategyMgr.setSpecifiedFilter(Settings.getPossibleFilters()[0].className);
            strategyMgr.setSpecifiedDisplayStrategy(settings.getPosibleDisplayStrategies()[0].className);
            strategyMgr.setSpecifiedGeneralTemplateUi(settings.getPossibleUiTemplateStrategies()[0].className);
            strategyMgr.getSpecifiedGeneralTemplateUi().setGeneratedGrantTrees(grantTrees);
            strategyMgr.getSpecifiedGeneralTemplateUi().setTreeOperation(treeOperation);
            List <GRANTManager.Strategy> posibleOS = settings.getPossibleOperationSystems();

            strategyMgr.setSpecifiedOperationSystem(settings.getPossibleOperationSystems()[0].className);
            strategyMgr.getSpecifiedFilter().setGeneratedGrantTrees(grantTrees);
            strategyMgr.getSpecifiedFilter().setTreeOperation(treeOperation);
            guiFuctions = new GuiFunctions(strategyMgr, grantTrees, treeOperation);

            pathToTemplate = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "Template");
            pathToTemplate = System.IO.Path.Combine(pathToTemplate, "TemplateUi.xml");
            //
            guiFuctions.deleteGrantTrees();
        }
Ejemplo n.º 2
0
    public void findHeuristics(SearchNodes start)
    {
        // Start searching row by row and calculate cost values for the nodes
        SearchNodes theStart = startingNode;
        SearchNodes nextNode = theStart;

        int   x1, x2, z1, z2;
        float cost;

        while (theStart != null)
        {
            while (nextNode != null)
            {
                // Use the manhattan distance as heuristic
                x1 = Mathf.FloorToInt(nextNode.transform.position.x);
                z1 = Mathf.FloorToInt(nextNode.transform.position.z);
                x2 = Mathf.FloorToInt(targetNode.transform.position.x);
                z2 = Mathf.FloorToInt(targetNode.transform.position.z);

                // Calculate cost
                cost = Mathf.Abs(x1 - x2) + Mathf.Abs(z1 - z2);
                nextNode.heuristicValue = (int)cost;
            }

            theStart = theStart.three;
            nextNode = theStart;
        }
    }
Ejemplo n.º 3
0
        public override string ToString()
        {
            if (SearchNodes != null)
            {
                var model = SearchNodes.FirstOrDefault(m => m.Url.Host.Contains(Host.Replace("www.", "")));

                if (model != null)
                {
                    return($"{Host}\t{Word}\t{Device}\t{model.Rank}");
                }
            }
            var rank = "0";

            if (SearchNodes == null)
            {
                rank = "0";
            }
            else if (SearchNodes.Any())
            {
                rank = SearchNodes.Last().Rank;
            }
            else
            {
                rank = SearchNodes.Count.ToString();
            }

            return($"{Host}\t{Word}\t{Device}\t{(SearchNodes != null ? rank : "100")}+");
            //return base.ToString();
        }
Ejemplo n.º 4
0
    public void findNodeCost(SearchNodes node1, SearchNodes node2)
    {
        int newMovementCost;


        // If there's no other nodes to search exit;
        if (node2 == null)
        {
            return;
        }


        // Check to see if targetNode was found
        if (node2 == targetNode)
        {
            targetNode.Init   = node1;
            targetNodeReached = true;
            return;
        }

        // Detect none walkable areas
        if (node2.gameObject.tag == "Agent" || node2.gameObject.tag == "Building" || node2.gameObject.tag == "Crate" ||
            node2.gameObject.tag == "TelephoneBooth" || node2.gameObject.tag == "Tower" || node2.gameObject.tag == "Wall" ||
            node2.gameObject.tag == "Woodfence")
        {
            return;
        }

        // Make sure that node wasn't already checked
        if (listClosed.Contains(node2) == false)
        {
            // Make sure the node is in the list of nodes that have not been checked
            if (listOpen.Contains(node2) == true)
            {
                // Get the new cost for the movement
                newMovementCost = node1.costOfMove + baseMoveCost;

                if (newMovementCost < node2.moveCost)
                {
                    // if new move cost is lower, then we found a
                    // a new node to use the search from
                    node2.Init       = node1;
                    node2.costOfMove = newMovementCost;
                    node2.findTotalCost();
                }
            }

            // Otherwise calculate the move cost and add it to open list
            else
            {
                node2.Init       = node1;
                node2.costOfMove = node1.costOfMove + baseMoveCost;
                node2.findTotalCost();
                AddToOpenList(node2);
            }
        }
    }
Ejemplo n.º 5
0
    public SearchNodes minTotalCost()
    {
        // Get the node with the minimum cost value
        float       min     = float.MaxValue;
        SearchNodes minNode = null;

        foreach (SearchNodes node in listOpen)
        {
            if (node.totalCost < min)
            {
                min     = node.totalCost;
                minNode = node;
            }
        }

        return(minNode);
    }
Ejemplo n.º 6
0
    public void findBestPath()
    {
        // Find the shortest path
        if (targetNodeReached == false)
        {
            if (checkNode.one != null)
            {
                findNodeCost(checkNode, checkNode.one);
            }

            if (checkNode.two != null)
            {
                findNodeCost(checkNode, checkNode.two);
            }

            if (checkNode.three != null)
            {
                findNodeCost(checkNode, checkNode.three);
            }

            if (checkNode.four != null)
            {
                findNodeCost(checkNode, checkNode.four);
            }

            // Move the current node to the close list
            // and remove from the open list
            AddToClosedList(checkNode);
            RemoveFromOpenList(checkNode);

            checkNode = minTotalCost();

            nodeNumber++;

            // Debug output
            print("Node # " + nodeNumber + " has been checked");
        }
    }
Ejemplo n.º 7
0
        public void Initialize()
        {
            strategyMgr = new StrategyManager();
            grantTrees  = new GeneratedGrantTrees();
            Settings settings = new Settings();

            searchNodes   = new SearchNodes(strategyMgr, grantTrees, treeOperation);
            treeOperation = new TreeOperation(strategyMgr, grantTrees);

            strategyMgr.setSpecifiedTree(settings.getPossibleTrees()[0].className);
            strategyMgr.setSpecifiedEventStrategy(settings.getPossibleEventManager()[0].className);
            strategyMgr.setSpecifiedFilter(Settings.getPossibleFilters()[0].className);
            strategyMgr.setSpecifiedDisplayStrategy(settings.getPosibleDisplayStrategies()[0].className);
            strategyMgr.setSpecifiedGeneralTemplateUi(settings.getPossibleUiTemplateStrategies()[0].className);
            strategyMgr.getSpecifiedGeneralTemplateUi().setGeneratedGrantTrees(grantTrees);
            strategyMgr.getSpecifiedGeneralTemplateUi().setTreeOperation(treeOperation);
            strategyMgr.getSpecifiedFilter().setGeneratedGrantTrees(grantTrees);
            List <GRANTManager.Strategy> posibleOS = settings.getPossibleOperationSystems();

            strategyMgr.setSpecifiedOperationSystem(settings.getPossibleOperationSystems()[0].className);
            strategyMgr.getSpecifiedFilter().setTreeOperation(treeOperation);
            guiFuctions = new GuiFunctions(strategyMgr, grantTrees, treeOperation);
        }
Ejemplo n.º 8
0
    // Modified adjacent sensor from assignment #1 to find adjacent nodes
    public void FindAdjacentNode()
    {
        RaycastHit hit;

        if (Physics.Raycast(this.transform.position, this.transform.forward, out hit) == true)
        {
            one = hit.collider.GetComponent <SearchNodes>();
        }

        if (Physics.Raycast(this.transform.position, this.transform.right, out hit) == true)
        {
            two = hit.collider.GetComponent <SearchNodes>();
        }

        if (Physics.Raycast(this.transform.position, this.transform.forward, out hit) == true)
        {
            three = hit.collider.GetComponent <SearchNodes>();
        }

        if (Physics.Raycast(this.transform.position, this.transform.right, out hit) == true)
        {
            four = hit.collider.GetComponent <SearchNodes>();
        }
    }
Ejemplo n.º 9
0
        private void InitializeFilterComponent()
        {
            settings      = new Settings();
            strategyMgr   = new StrategyManager();
            grantTree     = new GeneratedGrantTrees();
            searchNodes   = new SearchNodes(strategyMgr, grantTree, treeOperation);
            treeOperation = new TreeOperation(strategyMgr, grantTree);

            // Setzen des Eventmanager
            List <Strategy> possibleEventManager = settings.getPossibleEventManager();

            //abfrage der klassen, debugnamen, des typ für eintragung in strategy.confog - datei für entsprechende erstellung der klasse hier im manager
            //IEvent_PRISMStrategy test = new StrategyEvent_PRISM.Event_PRISM();
            //Type t = test.GetType();

            strategyMgr.setSpecifiedEventStrategy(possibleEventManager[0].className);

            #region setzen der neuen (Juni 2017) Event Interfaces
            strategyMgr.setSpecifiedEventAction(settings.getPossibleEventAction()[0].className);
            strategyMgr.getSpecifiedEventAction().setGrantTrees(grantTree);
            strategyMgr.getSpecifiedEventAction().setTreeOperation(treeOperation);
            strategyMgr.setSpecifiedEventManager(settings.getPossibleEventManager2()[0].className);
            strategyMgr.setSpecifiedEventProcessor(settings.getPossibleEventProcessor()[0].className);

            strategyMgr.getSpecifiedEventProcessor().setGrantTrees(grantTree);
            strategyMgr.getSpecifiedEventProcessor().setTreeOperations(treeOperation);

            //todo: neu, nur in example, noch an application machen
            strategyMgr.getSpecifiedEventManager().setGrantTrees(grantTree);
            strategyMgr.getSpecifiedEventManager().setTreeOperations(treeOperation);
            //test
            strategyMgr.getSpecifiedEventManager().EventExample();
            #endregion


            List <Strategy> possibleOperationSystems = settings.getPossibleOperationSystems();
            String          cUserOperationSystemName = possibleOperationSystems[0].userName; // muss dynamisch ermittelt werden
            strategyMgr.setSpecifiedOperationSystem(Settings.strategyUserNameToClassName(cUserOperationSystemName));

            List <Strategy> possibleTrees = settings.getPossibleTrees();
            strategyMgr.setSpecifiedTree(possibleTrees[0].className);



            List <Strategy> possibleFilter  = Settings.getPossibleFilters();
            String          cUserFilterName = possibleFilter[0].userName; // der Filter muss dynamisch ermittelt werden
            strategyMgr.setSpecifiedFilter(Settings.strategyUserNameToClassName(cUserFilterName));
            //  strategyMgr.getSpecifiedFilter().setStrategyMgr(strategyMgr);

            strategyMgr.setSpecifiedBrailleDisplay(settings.getPossibleBrailleDisplays()[0].className); // muss dynamisch ermittelt werden
            //if (strategyMgr.getSpecifiedBrailleDisplay() == null)
            {
                Settings settings = new Settings();
                strategyMgr.setSpecifiedBrailleDisplay(settings.getPossibleBrailleDisplays()[0].className); // muss dynamisch ermittelt werden

                strategyMgr.getSpecifiedBrailleDisplay().setStrategyMgr(strategyMgr);
                strategyMgr.getSpecifiedBrailleDisplay().setGeneratedGrantTrees(grantTree);
                strategyMgr.getSpecifiedBrailleDisplay().setTreeOperation(treeOperation);
                // strategyMgr.getSpecifiedBrailleDisplay().initializedSimulator();
                //strategyMgr.getSpecifiedBrailleDisplay().setActiveAdapter();
                //strategyMgr.getSpecifiedBrailleDisplay().generatedBrailleUi();
            }
            // brailleDisplayStrategy = strategyMgr.getSpecifiedBrailleDisplay();
            //  brailleDisplayStrategy.setStrategyMgr(strategyMgr);

            strategyMgr.setSpecifiedDisplayStrategy(settings.getPosibleDisplayStrategies()[0].className);

            strategyMgr.setSpecifiedGeneralTemplateUi(settings.getPossibleUiTemplateStrategies()[0].className);
            strategyMgr.getSpecifiedGeneralTemplateUi().setGeneratedGrantTrees(grantTree);
            strategyMgr.getSpecifiedGeneralTemplateUi().setTreeOperation(treeOperation);

            strategyMgr.getSpecifiedFilter().setGeneratedGrantTrees(grantTree);
            strategyMgr.getSpecifiedFilter().setTreeOperation(treeOperation);
            exampleTree       = new ExampleTree(strategyMgr, grantTree, treeOperation);
            exampleInspectGui = new InspectGui(strategyMgr);
            exampleBrailleDis = new ExampleBrailleDis(strategyMgr, grantTree, treeOperation);
            exampleDisplay    = new ExampleDisplayStrategy(strategyMgr);

            guiFunctions = new GuiFunctions(strategyMgr, grantTree, treeOperation);
        }
Ejemplo n.º 10
0
    public bool targetNodeReached = false;     // Used to check if target node was reached

    // Use this for initialization
    void Start()
    {
        findHeuristics(firstNode);
        checkNode = firstNode;
    }
Ejemplo n.º 11
0
 public void RemoveFromOpenList(SearchNodes node)
 {
     listOpen.Remove(node);
 }
Ejemplo n.º 12
0
 public void AddToClosedList(SearchNodes node)
 {
     listClosed.Add(node);
 }
Ejemplo n.º 13
0
 public void AddToOpenList(SearchNodes node)
 {
     listOpen.Add(node);
 }