Beispiel #1
0
        private void NextLabyrinthStep_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string[]  labyrinthData = File.ReadAllText("Data.txt").Split(';');
                int       width         = int.Parse(labyrinthData.First());
                int       height        = int.Parse(labyrinthData.ElementAt(1));
                Labyrinth labyrinth     = Labyrinth.GetActual(width, height);

                foreach (string relationData in labyrinthData.Skip(2))
                {
                    double[] relationPosition = relationData.Split('x').Select(d => double.Parse(d)).ToArray();

                    labyrinth[relationPosition[0], relationPosition[1]].Close();
                }

                lc.Robot.ActualPossibleRoute?.Cancel();
                lc.Robot.LearnMaybeRoute?.Cancel();
                lc.Robot.LearnPossibleRoute?.Cancel();
                lc.Robot.LearnRobotRoute?.Cancel();

                lc.Robot = new Robot(labyrinth);
            }
            catch { }
        }
Beispiel #2
0
        private static void OnBlocksHeightPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var s     = (LabyrinthControl)sender;
            var value = (int)e.NewValue;

            if (s.Robot.ActualLabyrinth.Height == value)
            {
                return;
            }
            s.Robot = new Robot(Labyrinth.GetActual(s.BlocksWidth, s.BlocksHeight));
        }