コード例 #1
0
        private void GenerateMazeButton_Click(object sender, EventArgs e)
        {
            var           size = (Convert.ToInt32(SizeTextBox.Text) - 1) * 2 + 1;
            var           rng  = new Random();
            BaseAlgorithm alg;

            switch (AlgorithmComboBox.SelectedIndex)
            {
            case 0:
                alg = new KruskalsAlgorithm(rng);
                break;

            case 1:
                alg = new RecursiveDivisionAlgorithm(rng);
                break;

            case 2:
                alg = new SidewinderAlgorithm(rng);
                break;

            case 3:
                alg = new GrowingTreeAlgorithm(rng);
                break;

            default:
                throw new Exception("Algorithm index not found");
            }
            new Thread(() => alg.GenerateMaze(size, ref _delayValue, ref _behaviorValue))
            {
                IsBackground = true
            }.Start();
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: m3Lith/ktu-maze
 private void GenerateMazeButton_Click(object sender, EventArgs e)
 {
     var size = (Convert.ToInt32(SizeTextBox.Text) - 1)*2 + 1;
     var rng = new Random();
     BaseAlgorithm alg;
     switch (AlgorithmComboBox.SelectedIndex)
     {
         case 0:
             alg = new KruskalsAlgorithm(rng);
             break;
         case 1:
             alg = new RecursiveDivisionAlgorithm(rng);
             break;
         case 2:
             alg = new SidewinderAlgorithm(rng);
             break;
         case 3:
             alg = new GrowingTreeAlgorithm(rng);
             break;
         default:
             throw new Exception("Algorithm index not found");
     }
     new Thread(() => alg.GenerateMaze(size, ref _delayValue, ref _behaviorValue)) {IsBackground = true}.Start();
 }