Esempio n. 1
0
        public void setConflicts(HashSet <TimedMove> ID_CAT, HashSet_U <TimedMove> CBS_CAT)
        {
            TimedMove m2 = new TimedMove();

            if (this.prevStep == null)
            {
                return;
            }
            for (int i = 0; i < allSteps.Length; i++)
            {
                m2.setup(allSteps[i].getX(), allSteps[i].getY(), Move.Direction.NO_DIRECTION, getDepth());
                if (ID_CAT != null && ID_CAT.Contains(m2))
                {
                    conflicts++;
                }
                if (CBS_CAT != null && CBS_CAT.Contains(m2))
                {
                    conflicts++;
                }
                m2.direction = Move.getDirection(allSteps[i].getX(), allSteps[i].getY(), prevStep.allSteps[i].getX(), prevStep.allSteps[i].getY());
                m2.setOppositeMove();
                if (ID_CAT != null && ID_CAT.Contains(m2))
                {
                    conflicts++;
                }
                if (CBS_CAT != null && CBS_CAT.Contains(m2))
                {
                    conflicts++;
                }
            }
        }
Esempio n. 2
0
        private LinkedList <Move>[] GetAnswer(MDDStep finish)
        {
            if (finish == null)
            {
                return(new LinkedList <Move> [1]);
            }
            LinkedList <Move>[] ans = new LinkedList <Move> [problem.Length];
            Move.Direction      direction;
            for (int i = 0; i < ans.Length; i++)
            {
                ans[i] = new LinkedList <Move>();
            }
            MDDStep current = finish;

            while (current.prevStep != null)
            {
                for (int i = 0; i < problem.Length; i++)
                {
                    direction = Move.getDirection(current.allSteps[i].getX(), current.allSteps[i].getY(), current.prevStep.allSteps[i].getX(), current.prevStep.allSteps[i].getY());
                    ans[i].AddFirst(new Move(current.allSteps[i].getX(), current.allSteps[i].getY(), direction));
                }
                current = current.prevStep;
            }
            for (int i = 0; i < problem.Length; i++)
            {
                ans[i].AddFirst(new Move(current.allSteps[i].getX(), current.allSteps[i].getY(), 0));
            }
            return(ans);
        }