Example #1
0
        public View()
        {
            InitializeComponent();

            PANEL_SIZE = panelMap.Size.Width;
            Simulation simulation = new Simulation();
            simulation.setAlgorithmType((AlgorithmType)algorithmType.SelectedIndex);
            simulation.setHeuristicMethod((Node.Method)heuristicMethod.SelectedIndex);
            simulation.set(ViewNumericUpDown.FieldOfView, FIELD_OF_VIEW_INIT);

            simulation.set(ViewNumericUpDown.NumberOfAgents, NUMBER_OF_AGENTS_INIT);
            simulation.set(ViewNumericUpDown.PercentWalkable, PERCENT_WALKABLE_INIT);
            simulation.set(ViewNumericUpDown.MaxSteps, MAX_STEPS_INIT);
            simulation.set(ViewNumericUpDown.StepDelay, STEP_DELAY_INIT);
            simulation.set(ViewNumericUpDown.MapSize, MAP_SIZE_INIT);
            simulation.setCellSize(CELL_SIZE_INT);

            Results results = new Results(this.simulationListView, new String[] {
                "Agent ID",
                "Map ID",
                "Field of View",
                "Steps",
                "Visible",
                "Visible Walkable",
                "Visible Non-Walkable",
                "Evaluated",
                "Shared",
                "Possible",
                "Success",

                "Algorithm",
                "Heuristic Method",

                "Field of View Method",
                "Cooperation",
                "Map Size",
                "% Walkalbe",
                "Agents",
            });
            Model model = new Model(simulation, results);
            controller = new Controller(model, this);

            eventHandlerInit(model);
            customViewInit(model);
        }
Example #2
0
        private void eventHandlerInit(Model model)
        {
            fieldOfView.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(fieldOfView, ViewNumericUpDown.FieldOfView);
            mapSize.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(mapSize, ViewNumericUpDown.MapSize);
            percentWalkable.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(percentWalkable, ViewNumericUpDown.PercentWalkable);
            numberOfAgents.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(numberOfAgents, ViewNumericUpDown.NumberOfAgents);
            maxSteps.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(maxSteps, ViewNumericUpDown.MaxSteps);
            stepDelay.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(stepDelay, ViewNumericUpDown.StepDelay);
            visualizationDelay.ValueChanged += (sender, eventArgs) => controller.NumericUpDown_ValueChanged(visualizationDelay, ViewNumericUpDown.VisualizationDelay);

            algorithmType.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(algorithmType, ViewComboBox.AlgorithmType);
            heuristicMethod.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(heuristicMethod, ViewComboBox.HeuristicMethod);
            fovMethod.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(fovMethod, ViewComboBox.FovMethod);
            agentCooperation.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(agentCooperation, ViewComboBox.AgentCooperation);
            viewableAgent.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(viewableAgent, ViewComboBox.ViewableAgent);
            pathPersistence.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(pathPersistence, ViewComboBox.PathPersistence);
            visualizations.SelectedIndexChanged += (sender, eventArgs) => controller.ComboBox_SelectedIndexChanged(visualizations, ViewComboBox.Visualizations);

            buttonRandomMap.Click += (sender, eventArgs) => controller.Button_Click(buttonRandomMap, ViewButton.RandomMap);
            buttonEmptyMap.Click += (sender, eventArgs) => controller.Button_Click(buttonEmptyMap, ViewButton.EmptyMap);
            buttonStart.Click += (sender, eventArgs) => controller.Button_Click(buttonStart, ViewButton.Start);
            buttonCancel.Click += (sender, eventArgs) => controller.Button_Click(buttonCancel, ViewButton.Cancel);
            buttonClearResults.Click += (sender, eventArgs) => controller.Button_Click(buttonClearResults, ViewButton.ClearResults);
            buttonExportCSV.Click += (sender, eventArgs) => controller.Button_Click(buttonExportCSV, ViewButton.ExportCsv);
            buttonResetMap.Click += (sender, eventArgs) => controller.Button_Click(buttonResetMap, ViewButton.ResetMap);

            radioButtonEditWalkable.Click += (sender, eventArgs) => controller.RadioButton_Click(radioButtonEditWalkable, ViewRadioButton.EditWalkable);
            radioButtonEditNonWalkable.Click += (sender, eventArgs) => controller.RadioButton_Click(radioButtonEditNonWalkable, ViewRadioButton.EditNonWalkable);
            radioButtonEditStart.Click += (sender, eventArgs) => controller.RadioButton_Click(radioButtonEditStart, ViewRadioButton.EditStart);
            radioButtonEditFinish.Click += (sender, eventArgs) => controller.RadioButton_Click(radioButtonEditFinish, ViewRadioButton.EditFinish);

            /* view class events */
            simulationListView.ColumnWidthChanging += new ColumnWidthChangingEventHandler(simulationListView_ColumnWidthChanging);
            simulationListView.ColumnClick += new ColumnClickEventHandler(simulationListView_ColumnClick);
        }
Example #3
0
        private void customViewInit(Model model)
        {
            /* Section:  AI Parameters */
            algorithmType.Items.Clear();
            algorithmType.Items.Add(AlgorithmType.Dijkstra);
            algorithmType.Items.Add(AlgorithmType.AStar);
            algorithmType.SelectedItem = AlgorithmType.AStar;
            heuristicMethod.Items.Clear();
            heuristicMethod.Items.Add(Node.Method.Euclidean);
            heuristicMethod.Items.Add(Node.Method.EuclideanSquared);
            heuristicMethod.Items.Add(Node.Method.Manhattan);
            heuristicMethod.Items.Add(Node.Method.Chebyshev);
            heuristicMethod.SelectedItem = Node.Method.Euclidean;
            fieldOfView.Value = FIELD_OF_VIEW_INIT;
            fovMethod.Items.Clear();
            fovMethod.Items.Add(Node.Method.Euclidean);
            fovMethod.Items.Add(Node.Method.EuclideanSquared);
            fovMethod.Items.Add(Node.Method.Manhattan);
            fovMethod.Items.Add(Node.Method.Chebyshev);
            fovMethod.SelectedItem = Node.Method.Euclidean;
            agentCooperation.Items.Clear();
            agentCooperation.Items.Add(AgentCooperation.Disabled);
            agentCooperation.Items.Add(AgentCooperation.Enabled);
            agentCooperation.SelectedItem = AgentCooperation.Enabled;

            /* Section:  Map Generator */
            mapSize.Value = MAP_SIZE_INIT;
            percentWalkable.Value = PERCENT_WALKABLE_INIT;
            numberOfAgents.Value = NUMBER_OF_AGENTS_INIT;

            /* Section:  Simulation Preferences */
            viewableAgent.Items.Clear();
            pathPersistence.Items.Clear();
            pathPersistence.Items.Add(PathPersistence.Disabled);
            pathPersistence.Items.Add(PathPersistence.Enabled);
            pathPersistence.SelectedItem = PathPersistence.Enabled;
            visualizations.Items.Clear();
            visualizations.Items.Add(Visualizations.Disabled);
            visualizations.Items.Add(Visualizations.Enabled);
            visualizations.SelectedItem = Visualizations.Disabled;
            maxSteps.Value = MAX_STEPS_INIT;
            stepDelay.Value = STEP_DELAY_INIT;
            visualizationDelay.Value = VISUALIZATION_DELAY_INIT;
            buttonStart.Enabled = false;
            buttonCancel.Enabled = false;

            /* Section:  Map */
            radioButtonEditWalkable.Enabled = false;
            radioButtonEditNonWalkable.Enabled = false;
            radioButtonEditStart.Enabled = false;
            radioButtonEditFinish.Enabled = false;
            buttonResetMap.Enabled = false;

            /* Section:  Help */
            this.status.Text = "Select Parameters then click Random or Empty Map";
        }