Esempio n. 1
0
        private void button_placement_alea_chariot_Click(object sender, EventArgs e) // Bonton placement aléaoire chariot
        {
            textBoxPosChar.Clear();
            btn_calcul_temps.Enabled    = true;
            btn_calcul_distance.Enabled = true;
            listBoxChar.Items.Clear();
            tabEntrepot = GenericNode.InitialiserEntrepot(); // On initialise le tableau "source"

            Random rd  = new Random();
            int    NBC = Convert.ToInt32(numericUpDown1.Value);

            tabChariot = new Chariot[NBC];//On initialise le tableau avec la taille de NBC

            for (int i = 0; i < tabChariot.Length; i++)
            {
                int posX = rd.Next(1, 25);
                int posY = rd.Next(1, 25);
                //On définit des position aléatoires tant que les valeurs correspondantes aux positions ne sont pas égales à 0 : un chariot ne doit pas être sur un obstacle
                while (GenericNode.tabEntrepot[posX - 1, posY - 1] < 0) // -1 car le tableau est décalé
                {
                    posX = rd.Next(1, 25);
                    posY = rd.Next(1, 25);
                }
                tabChariot[i] = new Chariot(posX, posY);          //On crée un nouveau chariot que l'on stocke dans le tableau
                GenericNode.tabEntrepot[posX - 1, posY - 1] = -1; //on remplace la valeur dans notre tableau global de l'entrepot correspondante aux positions du chariot  par -1 pour pas qu'un chariot puisse apparaitre sur un chariot prédéfini et que tout chariot soit considéré comme un obstacle
            }

            foreach (Chariot c in tabChariot)
            {
                listBoxChar.Items.Add(c);//On ajoute chaque chariot à la listBox pour pouvoir par la suite en séléctionner un.
            }
        }
        private int ChariotProche(Colis colis)
        {
            // initialisation du chariot que l'on teste : ici le premier du tableau
            Chariot chariot_choisit = Program.tab_chariot[0];
            // on met un cout par défaut très grand
            double      cost     = 1000000;
            Emplacement empColis = new Emplacement(colis._x, colis._y, colis._orientation, colis._hauteur);

            // on passe en revue tous les chariots du tableau pour voir quel chariot est le plus proche du colis.
            foreach (Chariot chariot in Program.tab_chariot)
            {
                if (!chariot.enLivraison)
                {
                    Emplacement empChariot = new Emplacement(chariot._x, chariot._y, chariot._orientation, 0);

                    // Calcul du cout théorique du déplacement
                    empChariot.CalculeHCost(empColis);

                    // Comparaison
                    if (empChariot.Estimation() < cost)
                    {
                        chariot_choisit = chariot;
                        cost            = empChariot.Estimation();
                    }
                }
            }
            return(chariot_choisit.Get_cle_chariot() - 1);
        }
Esempio n. 3
0
 private void listBoxChar_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxChar.SelectedItem != null)
     {
         textBoxPosChar.Text = listBoxChar.SelectedItem.ToString();
         label_error.Visible = false;
         charChoisi          = (Chariot)listBoxChar.SelectedItem;
     }
 }// Methode pour sélection du chariot dans la listBox
Esempio n. 4
0
        }// Methode pour sélection du chariot dans la listBox

        private void btn_ajout_chariot_Click(object sender, EventArgs e) // bouton AjoutChariot
        {
            compteurCharMan++;
            Chariot c = new Chariot(int.Parse(textBoxX.Text), int.Parse(textBoxY.Text));

            listBoxChar.Items.Add(c);
            countNbCharMan.Text = (compteurCharMan + 1).ToString();
            textBoxX.Clear();
            textBoxY.Clear();
            tabChariot[compteurCharMan - 1] = c;
            GenericNode.tabEntrepot[c.posX - 1, c.posY - 1] = -1;
            if (compteurCharMan == Convert.ToInt32(numericUpDown1.Value))
            {
                btn_calcul_temps.Enabled    = true;
                btn_calcul_distance.Enabled = true;
                btn_ajout_chariot.Enabled   = false;
                textBoxX.Enabled            = false;
                textBoxY.Enabled            = false;
                countNbCharMan.Text         = (compteurCharMan).ToString();
            }
        }
Esempio n. 5
0
        public Information_arbre(List <GenericNode> chemin, Graph nul, Chariot chariot_choisi)
        {
            InitializeComponent();
            Affichage_Arbre_TV.Visible = true;
            Chemin_LIST.Visible        = true;

            if (chemin.Count == 0)
            {
                Ouvert_LBL.Text = " ... ";
                Fermes_LBL.Text = "...";
                Final_LBL.Text  = "Pas de solution";
            }
            else
            {
                Final_LBL.Text = "Une solution a été trouvée";
                foreach (GenericNode N in chemin)
                {
                    Chemin_LIST.Items.Add(N);
                }
                Ouvert_LBL.Text = "Nb noeuds des ouverts : " + nul.CountInOpenList().ToString();
                Fermes_LBL.Text = "Nb noeuds des fermés : " + nul.CountInClosedList().ToString();
                nul.GetSearchTree(Affichage_Arbre_TV);
            }
        }
Esempio n. 6
0
        private void tmpButton_Click(object sender, EventArgs e)
        {
            // Expression regulière pour récuperer la position d'un chariot avec le nom du bouton
            Regex  re = new Regex(@"([0-9]*)\.([0-9]*)");
            String sourcestring;

            // Retrouver le bouton et le changer de couleur puis le bloquer
            Button btn = (Button)sender;

            if (nbChariotsClick < Program.tab_chariot.Length - 1)
            {
                btn.Enabled           = false;
                Aleatoire_BTN.Visible = false;
                // Recuperer les coordonnées du bouton et ajouter le chariot correspondant
                sourcestring = btn.Name;

                MatchCollection mc = re.Matches(sourcestring);

                // Création des chariots
                foreach (Match match in mc)
                {
                    Program.tab_chariot[nbChariotsClick] = new Chariot(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value));
                    Program.entrepot.cell[int.Parse(match.Groups[2].Value), int.Parse(match.Groups[1].Value)] = 2;
                    btn.Text = "" + Program.tab_chariot[nbChariotsClick].Get_cle_chariot();
                }
                btn.Image            = btn.Image = Image.FromFile("../../Images/" + Program.tab_chariot[nbChariotsClick]._orientation + ".png");
                Consigne_LBL.Visible = true;
                // car les indices sont décalées de 1, il faut donc mettre un -1 pour avoir un affichage correct
                Consigne_LBL.Text = "Etape 1 : Veuillez placer les " + (Program.tab_chariot.Length - nbChariotsClick - 1) + " restants";
                nbChariotsClick++;
            }
            else if (nbChariotsClick == Program.tab_chariot.Length - 1)
            {
                /* Création du dernier chariot */

                btn.Enabled = false;

                sourcestring = btn.Name;

                MatchCollection mc = re.Matches(sourcestring);

                // Création des chariots
                foreach (Match match in mc)
                {
                    Program.tab_chariot[nbChariotsClick] = new Chariot(int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value));
                    btn.Text = "" + Program.tab_chariot[nbChariotsClick].Get_cle_chariot();
                    Program.entrepot.cell[int.Parse(match.Groups[2].Value), int.Parse(match.Groups[1].Value)] = 2;
                }

                btn.Image            = btn.Image = Image.FromFile("../../Images/" + Program.tab_chariot[nbChariotsClick]._orientation + ".png");
                Consigne_LBL.Visible = true;
                Consigne_LBL.Text    = "Etape 2 : Veuillez choisir un chariot en cliquant sur son emplacement dans le graphique";
                UnableBtn(false);
                nbChariotsClick++;
            }
            else if (nbChariotsClick == Program.tab_chariot.Length && btn.Image != null)
            {
                Chariot_choisi      = Program.tab_chariot[int.Parse(btn.Text) - 1];
                Valider_BTN.Enabled = true;
                Affichage_colis();
                //on affiche la 4ième étape
                Consigne_LBL.Text = "Etape 3 : Définir un colis";
                UnableBtn(false);
            }
        }