Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int jugable    = 0;
            int no_jugable = 0;

            for (int k = 0; k < 1; k++)
            {
                //1 = goomba 0.01
                //2 = soild 0,1
                //3 = ladrillo 0,136
                //4 = coin 0,012
                //5 = pipe 0,009
                //6 = koopa 0,008
                List <double> elements = new List <double>()
                {
                    1, 2, 3, 4, 5, 6
                };
                List <double> pdf = new List <double>()
                {
                    0.01f, 0.1f, 0.136f, 0.012f, 0.009f, 0.008f
                };
                double p = new System.Random((int)DateTime.Now.Ticks).NextDouble();
                temp1 = Superva(elements, pdf, p);

                richTextBox1.Text = string.Empty;
                for (int i = 0; i <= n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        richTextBox1.Text += temp1[i, j].ToString() + "   ";
                    }
                    richTextBox1.Text += System.Environment.NewLine;
                }

                coord start = new coord(n - 1, 0);
                coord end   = new coord(n - 1, m - 1);

                if (bread_first_traversal(start, end, temp1))
                {
                    label1.Text = "Jugable";
                    jugable++;
                }
                else
                {
                    label1.Text = "No Jugable";
                    no_jugable++;
                }
            }
            label1.Text = jugable.ToString() + "::" + no_jugable.ToString();
        }
Пример #2
0
        bool bread_first_traversal(coord start, coord end, double[,] world)
        {
            List <coord> queue = new List <coord>();

            queue.Add(start);
            world[start.X, start.Y] = 8;
            while (queue.Count > 0)
            {
                coord current = queue[queue.Count - 1];
                queue.Remove(current);
                if (current.X >= 0 && current.Y == m - 1)
                {
                    richTextBox2.Text = string.Empty;
                    for (int i = 0; i <= n; i++)
                    {
                        for (int j = 0; j < m; j++)
                        {
                            richTextBox2.Text += world[i, j].ToString() + "   ";
                        }
                        richTextBox2.Text += System.Environment.NewLine;
                    }
                    return(true);
                }
                foreach (coord c in next_Positions(current.X, current.Y))
                {
                    if (isValid(c.X, c.Y, n, m) && (world[c.X, c.Y] == 0 || world[c.X, c.Y] == 1 || world[c.X, c.Y] == 6))
                    {
                        world[c.X, c.Y] = 8;
                        queue.Add(new coord(c.X, c.Y));
                    }
                }
            }
            richTextBox2.Text = string.Empty;
            for (int i = 0; i <= n; i++)
            {
                for (int j = 0; j < m; j++)
                {
                    richTextBox2.Text += world[i, j].ToString() + "   ";
                }
                richTextBox2.Text += System.Environment.NewLine;
            }
            return(false);
        }