Esempio n. 1
0
 private void GenerateArena()
 {
     Start[0] = 1; Start[1] = 1;
     Goal[0]  = rd.Next(2, 8); Goal[1] = rd.Next(2, 8);
     for (int row = 0; row < RMAX; row++)
     {
         for (int col = 0; col < CMAX; col++)
         {
             arenaMaze[row, col]           = new ArenaMaze(row, col, Goal[0], Goal[1]);
             arenaMaze[row, col].ForeColor = Color.Red;
             arenaMaze[row, col].BackColor = Color.Silver;
             arenaMaze[row, col].Size      = new Size(49, 49);
             arenaMaze[row, col].Location  = new Point(col * 50, row * 50);
             panel1.Controls.Add(arenaMaze[row, col]);
             if (row == 0 || col == 0 || col == CMAX - 1 || row == CMAX - 1)
             {
                 arenaMaze[row, col].BackColor = Color.Red;
                 arenaMaze[row, col].Status    = false;
             }
             else if ((row == 1 && col == 1) || (row == Goal[0] && col == Goal[1]))
             {
                 arenaMaze[row, col].BackColor = Color.Green;
             }
         }
     }
     agen = new Agent(Goal);
     arenaMaze[Start[0], Start[1]].Head = null;
     panel1.BorderStyle = BorderStyle.Fixed3D;
     panel1.Size        = new Size(50 * CMAX, 50 * RMAX);
     panel1.ForeColor   = Color.Black;
 }
Esempio n. 2
0
        //memasukan jalur yang effisien ke stack
        private void traceBack(ArenaMaze nodeTmp)
        {
            ArenaMaze x;

            while (nodeTmp.Head != null)
            {
                movementsList.Push(nodeTmp);
                x       = nodeTmp.Head;
                nodeTmp = x;
            }
        }
Esempio n. 3
0
        public ArenaMaze minimalHeuristik(List <ArenaMaze> nodes)
        {
            ArenaMaze tmp = nodes[0];

            foreach (ArenaMaze item in nodes)
            {
                if (item.Heuristik < tmp.Heuristik)
                {
                    tmp = item;
                }
            }
            return(tmp);
        }
Esempio n. 4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            ArenaMaze tmp = movements.Dequeue();

            arenaMaze[tmp.Row, tmp.Col].BackColor = Color.Gold;
            arenaMaze[tmp.Row, tmp.Col].Text      = (this.counter++).ToString();
            Keterangan_Label.Text = "Coordinate Y,X =" + tmp.Row + "," + tmp.Col;
            if (agen.isAgentGoal(tmp.Row, tmp.Col) || movements.Count <= 0)
            {
                traceBack(arenaMaze[tmp.Row, tmp.Col]);
                MarkingRoute();
                timer1.Stop(); this.counter = 0;
            }
        }
Esempio n. 5
0
 public void enqueue(ArenaMaze x)
 {
     queue[_tail] = x;
     _tail++;
 }