示例#1
0
        private void start_algorithm(object sender, EventArgs e)
        {
            change_enabled_setting(); //Toggle controls
            AlgorithmState.StartAlgorithm();

            FormsHandler.LoadAndDisplayState(AlgorithmState.GetCurrentState());
        }
示例#2
0
 private void comboboxQmatrixselect_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!FormsHandler.lock_index_change_events && ((ComboBox)sender).SelectedIndex > -1)
     {
         FormsHandler.large_dropdown_changed();
     }
 }
示例#3
0
 public void EraseBoardForReset()
 {                              //Used ONLY with the restart algorithm button. Keeps a few old things, like bender's position and settings
     algorithm_started = false; //Algorithm no longer running
     InitializeValues();
     state_history = new List <AlgorithmEpisode>();
     state_history.Add(new AlgorithmEpisode(1));
     FormsHandler.ResetConfiguration();
 }
示例#4
0
 private void qmatrix_small_dropdown_changed(object sender, EventArgs e)
 {
     if (!FormsHandler.lock_index_change_events && ((ComboBox)sender).SelectedIndex > -1)
     {
         if (((ComboBox)sender).SelectedText != "None.")
         {
             FormsHandler.small_dropdown_changed((ComboBox)sender);
         }
     }
 }
示例#5
0
        private void set_steps_from_dropdown(object sender, EventArgs e)
        {
            bool success = Int32.TryParse(comboboxSteps.Text, out int result);

            if (!success)
            {
                comboboxSteps.Text = "Invalid.";
            }
            else
            {
                Qmatrix.step_limit = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxMovedwithoutwall.Text, out double result);

            if (!success)
            {
                comboboxMovedwithoutwall.Text = "Invalid.";
            }
            else
            {
                MoveResult.list[MoveResult.move_successful()] = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#7
0
        private void button4_Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxWallpunishment.Text, out double result);

            if (!success)
            {
                comboboxWallpunishment.Text = "Invalid.";
            }
            else
            {
                MoveResult.list[MoveResult.MoveFailed] = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#8
0
        private void button2_Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxE.Text, out double result);

            if (!success)
            {
                comboboxE.Text = "Invalid.";
            }
            else
            {
                FormsHandler.loaded_state.live_qmatrix.e_current = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#9
0
        private void set_y_from_dropdown(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxY.Text, out double result);

            if (!success)
            {
                comboboxY.Text = "Invalid.";
            }
            else
            {
                FormsHandler.loaded_state.live_qmatrix.y_current = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#10
0
        private void button6_Click(object sender, EventArgs e)
        {
            bool success = double.TryParse(comboboxEmptysquare.Text, out double result);

            if (!success)
            {
                comboboxEmptysquare.Text = "Invalid.";
            }
            else
            {
                MoveResult.list[MoveResult.CanMissing] = result;
                FormsHandler.DisplayInitialSettings();
            }
        }
示例#11
0
 private void comboboxHistorystep_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         bool success = Int32.TryParse(comboboxHistorystep.Text, out int result);
         if (!success || result < 1 || result > comboboxHistorystep.Items.Count)
         {
             comboboxHistorystep.Text = "Invalid.";
         }
         else
         {
             comboboxHistorystep.SelectedIndex = result;
             FormsHandler.LoadAndDisplayState((AlgorithmState)comboboxHistorystep.SelectedItem);
         }
     }
 }
示例#12
0
        private void history_index_changed(object sender, EventArgs e)
        {
            ComboBox sender_box = (ComboBox)sender;

            if (sender_box.SelectedIndex > -1)
            {
                comboboxHistorystep.Items.Clear();

                AlgorithmEpisode to_display = (AlgorithmEpisode)sender_box.SelectedItem;
                comboboxHistorystep.Items.AddRange(to_display.state_history_data.ToArray());
                comboboxHistorystep.SelectedIndex = 0;

                AlgorithmState state_to_display = (AlgorithmState)comboboxHistorystep.Items[0];
                FormsHandler.LoadAndDisplayState(state_to_display);
            }
        }
示例#13
0
        //Advance algorithm button
        async private void buttonAdvancestepsdropdown_Click(object sender, EventArgs e)
        {
            FormsHandler.halted = false;
            int steps_to_take = Int32.Parse(comboboxAdvancesteps.Text);
            int episodes      = Int32.Parse(comboboxAdvanceepisodes.Text);

            if (episodes > 0)
            {
                steps_to_take += (Int32.Parse(comboboxAdvanceepisodes.Text) * FormsHandler.loaded_state.GetStepLimit()) + 1; //+1 to get the new episode generated
            }
            int initial_delay = Int32.Parse(comboboxDelayms.Text);
            int delay         = initial_delay;

            if (steps_to_take > 1)
            {
                textboxProgresssteps.Text         = steps_to_take.ToString();
                groupboxCountdown.Enabled         = true;
                groupboxAlgorithmprogress.Enabled = false;
                groupboxHistory.Enabled           = false;
                while (steps_to_take-- > 0 && !FormsHandler.halted)
                {
                    AlgorithmState.PrepareStep();
                    FormsHandler.LoadAndDisplayState(AlgorithmState.GetCurrentState());
                    textboxProgresssteps.Text = steps_to_take.ToString();
                    do
                    {
                        await Task.Delay(1);

                        textboxCountdown.Text = delay.ToString();
                    } while (--delay > 0 && !FormsHandler.halted);
                    delay = initial_delay;
                }
                groupboxAlgorithmprogress.Enabled = true;
                groupboxCountdown.Enabled         = false;
                groupboxHistory.Enabled           = true;
            }

            else
            {
                AlgorithmState.PrepareStep();
                FormsHandler.LoadAndDisplayState(AlgorithmState.GetCurrentState());
            }
        }
示例#14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            AlgorithmState.SetDefaultConfiguration();


            //Second entry point of the program.
            //When the form loads, we'll create some pictureboxes, that will function as the robot world grid.


            PictureBox    picturebox_in_progress; //Temporary picturebox
            PictureSquare square_to_build;        //This is object inherits from boardSquare, but has a picture element.

            //Create pictureboxes and pass them to our board
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    //Fill in the column with rows
                    picturebox_in_progress          = new PictureBox();
                    square_to_build                 = new PictureSquare();
                    picturebox_in_progress.Name     = i.ToString() + "-" + j.ToString(); //Each name is the coordinate
                    picturebox_in_progress.Location =
                        new Point(InitialSettings.x_offset() + (i * InitialSettings.edge_length()),
                                  InitialSettings.y_offset() + (j * InitialSettings.edge_length()));
                    picturebox_in_progress.Size     = new Size(InitialSettings.edge_length(), InitialSettings.edge_length());
                    picturebox_in_progress.SizeMode = PictureBoxSizeMode.StretchImage;
                    picturebox_in_progress.BackgroundImageLayout = ImageLayout.Stretch;
                    Controls.Add(picturebox_in_progress);
                    square_to_build.pictureData = picturebox_in_progress;
                    FormsHandler.Add(i, 9 - j, square_to_build); //9-j to handle the board layout, for some reason!
                }
            }

            //Called from the restart button, but works here on initial launch.
            //This triggers the constructor for algorithm manager, as well

            textboxStatus.Text = "Program launched.";

            FormsHandler.DisplayState(); //First time we display the board.
        }
示例#15
0
        private void restart_algorithm_button_click(object sender, EventArgs e)
        {
            FormsHandler.StopAlgorithm(AlgorithmState.GetCurrentState());

            change_enabled_setting(); //Togle controls
        }
示例#16
0
        private void comboboxHistorystep_SelectedIndexChanged(object sender, EventArgs e)
        {
            AlgorithmState state_to_dislay = (AlgorithmState)((ComboBox)sender).SelectedItem;

            FormsHandler.LoadAndDisplayState(state_to_dislay);
        }
示例#17
0
 private void reset_config_button_click(object sender, EventArgs e)
 {
     FormsHandler.ResetConfiguration();
 }