private int UseSubgoalAStar(int x, int centerY)
        {
            Log.LogInformation("Driver Subgoal AStar - Subgoal AStar start");

            int s = 1;

            while (!CircleAgent.obstacleOpenSpace[centerY + s, x])
            {
                s++;
            }
            Node square = new Node(x, centerY + s - 1, false);

            this.nodes[0] = square;
            int y = square.getY();

            deleteCollectedDiamonds();

            List <int> diamondNodes = new List <int>();

            for (int n = 0; n < nodes.Count; n++)
            {
                if (nodes[n].getDiamond())
                {
                    diamondNodes.Add(n);
                }
            }

            CircleAgent.nodes = this.nodes;
            CircleAgent.CreateEdgesAndAdjacencyMatrix();
            this.adjacencyMatrix = CircleAgent.adjacencyMatrix;
            this.directionMap    = CircleAgent.directionMap;

            SubgoalAStar sgAstar = new SubgoalAStar(0, diamondNodes, 2000, 0);

            route = sgAstar.Run();
            int diamondsToCollect = diamondNodes.Count - 1;

            while (route == null)
            {
                sgAstar = new SubgoalAStar(0, diamondNodes, 2000, diamondsToCollect);
                route   = sgAstar.Run();
                diamondsToCollect--;
                if (diamondsToCollect == 0)
                {
                    route = new Queue <Node>();
                }
            }

            return(recalcNextNodes("Subgoal AStar", x, y));
        }
Exemplo n.º 2
0
 public CircleWorldModel(CircleAgent agent)
     : base()
 {
     platformManager = new CirclePlatformManager(this);
     this.agent      = agent;
 }