public void Init(AgentHandlerConstructionParameters par)
        {
            label_agentName.ForeColor = par.color;
            label_agentName.Text      = AgentTypeToString(par.type);

            Update();
        }
        public AgentHandler(AgentHandlerConstructionParameters param)
        {
            stopWatch_procTime = new Stopwatch();
            stopWatch_runTime  = new Stopwatch();
            runTime_previous   = new TimeSpan(0);

            if (speedLimitEnabled)
            {
                timer          = new Timer(waitTime);
                timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
                timer.Enabled  = false;
            }

            switch (param.type)
            {
            case AgentType.Omniscient:
                agent = new Agents.Omniscient(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            case AgentType.AStarOptimistic:
                agent = new Agents.AStarOptimistic(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            case AgentType.AStarPessimistic:
                agent = new Agents.AStarPessimistic(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            case AgentType.DStarOriginal:
                agent = new Agents.DStarOriginal(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            case AgentType.DStarFocused:
                agent = new Agents.DStarFocused(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            case AgentType.DStarLite:
                agent = new Agents.DStarLite(param.map, param.startX, param.startY, param.goalX, param.goalY);
                break;

            default:
                throw new System.ComponentModel.InvalidEnumArgumentException();
            }
            color   = param.color;
            stopped = false;
            busy    = false;
        }
        private void InitializeAgentHandlers()
        {
            int agentsNumber = 0;

            Agents.AgentBase.sightRange    = (UInt16)numericUpDown_sightRange.Value;
            AgentHandler.speedLimitEnabled = checkBox_speedLimit.Checked;
            AgentHandler.waitTime          = checkBox_speedLimit.Checked ? 1000 / trackBar_speed.Value : 0;

            List <ComboBox> comboBoxes = new List <ComboBox> (4);

            comboBoxes.Add(comboBox1);
            comboBoxes.Add(comboBox2);
            comboBoxes.Add(comboBox3);
            comboBoxes.Add(comboBox4);

            foreach (ComboBox cb in comboBoxes)
            {
                if (cb.SelectedIndex != 0)
                {
                    agentsNumber++;
                }
            }
            agentParams = new List <AgentHandlerConstructionParameters> (agentsNumber);

            if (comboBox1.SelectedIndex != 0)
            {
                AgentHandlerConstructionParameters par1 = new AgentHandlerConstructionParameters();
                par1.type   = GetAgentTypeFromComboBox(comboBox1);
                par1.map    = generatedMap;
                par1.color  = label_color1.BackColor;
                par1.startX = generatedMap.size / 8;
                par1.startY = generatedMap.size / 8;
                par1.goalX  = 7 * generatedMap.size / 8;
                par1.goalY  = 7 * generatedMap.size / 8;
                agentParams.Add(par1);
            }

            if (comboBox2.SelectedIndex != 0)
            {
                AgentHandlerConstructionParameters par2 = new AgentHandlerConstructionParameters();
                par2.type   = GetAgentTypeFromComboBox(comboBox2);
                par2.map    = generatedMap;
                par2.color  = label_color2.BackColor;
                par2.startX = generatedMap.size / 8;
                par2.startY = generatedMap.size / 8;
                par2.goalX  = 7 * generatedMap.size / 8;
                par2.goalY  = 7 * generatedMap.size / 8;
                agentParams.Add(par2);
            }

            if (comboBox3.SelectedIndex != 0)
            {
                AgentHandlerConstructionParameters par3 = new AgentHandlerConstructionParameters();
                par3.type   = GetAgentTypeFromComboBox(comboBox3);
                par3.map    = generatedMap;
                par3.color  = label_color3.BackColor;
                par3.startX = generatedMap.size / 8;
                par3.startY = generatedMap.size / 8;
                par3.goalX  = 7 * generatedMap.size / 8;
                par3.goalY  = 7 * generatedMap.size / 8;
                agentParams.Add(par3);
            }

            if (comboBox4.SelectedIndex != 0)
            {
                AgentHandlerConstructionParameters par4 = new AgentHandlerConstructionParameters();
                par4.type   = GetAgentTypeFromComboBox(comboBox4);
                par4.map    = generatedMap;
                par4.color  = label_color4.BackColor;
                par4.startX = generatedMap.size / 8;
                par4.startY = generatedMap.size / 8;
                par4.goalX  = 7 * generatedMap.size / 8;
                par4.goalY  = 7 * generatedMap.size / 8;
                agentParams.Add(par4);
            }
        }