示例#1
0
        public void Run()
        {
            if (run == false)
            {
                a_Star = new A_Star();
                a_Star.ActualStepChanged += new EventHandler(OnActualStepChanged);
                a_Star.EndNode            = CreateTreeNode(tileEnd.BoardPositionX, tileEnd.BoardPositionY, a_Star);
                a_Star.StartNode          = CreateTreeNode(tileStart.BoardPositionX, tileStart.BoardPositionY, a_Star);

                solutionFound  = false;
                endReached     = false;
                SolutionLength = 0;

                foreach (Tile tile in tileMap)
                {
                    if (tile.Type == Tile.TileType.Red || tile.Type == Tile.TileType.Blue || tile.Type == Tile.TileType.Green)
                    {
                        tile.Type = Tile.TileType.White;
                    }
                }

                run       = true;
                isStartet = true;
            }
        }
示例#2
0
        private static TreeNode_Base CreateTreeNode(int x, int y, A_Star a_Star_Reference)
        {
            switch (searchAlgorithm)
            {
            case TreeNode_Base.SearchAlgorithm.Greedy_Search:
                return(new TreeNode_Greedy_Search(x, y, a_Star_Reference, searchAlgorithm));

            case TreeNode_Base.SearchAlgorithm.A_Star:
                return(new TreeNode_A_Star(x, y, a_Star_Reference, searchAlgorithm));

            case TreeNode_Base.SearchAlgorithm.Breadth_First:
                return(new TreeNode_Breadth_First(x, y, a_Star_Reference, searchAlgorithm));

            case TreeNode_Base.SearchAlgorithm.Depth_First:
                return(new TreeNode_Depth_First(x, y, a_Star_Reference, searchAlgorithm));

            default:
                throw new NotSupportedException();
            }
        }
示例#3
0
 public TreeNode_Base_Board(int x, int y, A_Star a_Star_Class_Reference, SearchAlgorithm searchAlgorithm)
     : base(a_Star_Class_Reference, searchAlgorithm)
 {
     X = x;
     Y = y;
 }
示例#4
0
 public TreeNode_Depth_First(int x, int y, A_Star a_Star_Class_Reference, SearchAlgorithm searchAlgorithm)
     : base(x, y, a_Star_Class_Reference, searchAlgorithm)
 {
 }
示例#5
0
 public TreeNode_Greedy_Search(int x, int y, A_Star a_Star_Class_Reference, SearchAlgorithm searchAlgorithm)
     : base(x, y, a_Star_Class_Reference, searchAlgorithm)
 {
 }
示例#6
0
 public TreeNode_Base(A_Star a_Star_Class_Reference, SearchAlgorithm searchAlgorithm)
 {
     A_Star_Class_Reference = a_Star_Class_Reference;
     this.searchAlgorithm   = searchAlgorithm;
 }