Example #1
0
        public void CreatePathUsingBFS(MazeButton mazeButton)
        {
            var queue = new Queue <MazeButton>();

            mazeButton.IsVisited = true;
            queue.Enqueue(mazeButton);
            while (queue.Count != 0)
            {
                var e           = queue.Dequeue();
                int buttonIndex = ButtonsList.IndexOf(e);

                foreach (var btn in GetAdjacent(buttonIndex))
                {
                    if (btn == MazeEndPoint)
                    {
                        MazeEndPoint.Previous = e;
                        return;
                    }
                    if (!btn.IsVisited && !btn.IsBlock)
                    {
                        btn.Previous  = e;
                        btn.IsVisited = true;

                        queue.Enqueue(btn);
                    }
                }
            }
        }
Example #2
0
        public void CreatePathUsingDFS(MazeButton mazeButton)
        {
            mazeButton.IsVisited = true;

            int buttonIndex = ButtonsList.IndexOf(mazeButton);

            foreach (var btn in GetAdjacent(buttonIndex))
            {
                if (!btn.IsVisited && !btn.IsBlock)
                {
                    btn.Previous = mazeButton;
                    CreatePathUsingDFS(btn);
                }
            }
        }
Example #3
0
        public void RecreateButtons(int buttons)
        {
            mainArea.Background = Brushes.White;

            for (int i = 0; i < buttons; i++)
            {
                var createdButton = new MazeButton()
                {
                    Width        = 20,
                    Height       = 20,
                    IsBlock      = false,
                    IsEndPoint   = false,
                    IsStartPoint = false,
                    IsVisited    = false,
                    Father       = this,
                    //Content = i
                };
                ButtonsList.Add(createdButton);
                mainArea.Children.Add(createdButton);
            }
        }