Ejemplo n.º 1
0
        public void Hole_Restore(int[][] World_Data, Evento[] Event_List, int Xpos, int Ypos, double Lambda_Huecos)
        {
            Distribution dist = new Distribution();

            for (int c = 0; c < Event_List.Length; c++)
            {
                if (Event_List[c].GetType() == Hole)
                {
                    Hueco hole = (Hueco)Event_List[c];
                    if ((hole.Xpos == Xpos) && (hole.Ypos == Ypos))
                    {
                        for (int i = 0; i < World_Data.Length; i++)
                        {
                            for (int k = 0; k < World_Data[0].Length; k++)
                            {
                                if (World_Data[i][k] == 20)
                                {
                                    hole.Xpos             = k;
                                    hole.Ypos             = i;
                                    hole.Time_of_reaction = dist.nextExponential(Lambda_Huecos);
                                    break;
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public int[][] Hole_Moving(int[][] World_Data, Hueco hole)
        {
            Random Uniform_Distribution = new Random();
            int    Hole_X_Pos, Hole_Y_Pos = 0;

            Hole_X_Pos = Uniform_Distribution.Next(41);
            Hole_Y_Pos = Uniform_Distribution.Next(22);
            while (World_Data[Hole_Y_Pos][Hole_X_Pos] != 0)
            {
                Hole_X_Pos = Uniform_Distribution.Next(41);
                Hole_Y_Pos = Uniform_Distribution.Next(22);
            }
            World_Data[Hole_Y_Pos][Hole_X_Pos] = 2;
            hole.Xpos = Hole_X_Pos;
            hole.Ypos = Hole_Y_Pos;
            return(World_Data);
        }
Ejemplo n.º 3
0
        public int[][] Build_Huecos(int[][] World_Data, int Cant, double Lambda_Huecos)
        {
            Hueco_list = new Hueco[Cant];
            double       Time_of_existence;
            Random       Uniform_Distribution = new Random();
            Distribution Builder = new Distribution();
            int          Xcord, Ycord = 0;

            for (int i = 1; i <= Cant; i++)
            {
                Xcord = Uniform_Distribution.Next(40); //El 23 y el 43 son los índices de la matrix del mundo.
                Ycord = Uniform_Distribution.Next(21);
                while (World_Data[Ycord][Xcord] != 0)
                {
                    Xcord = Uniform_Distribution.Next(40);
                    Ycord = Uniform_Distribution.Next(21);
                }
                Time_of_existence        = Builder.nextExponential(Lambda_Huecos);
                Hueco_list[i - 1]        = new Hueco(Xcord, Ycord, Time_of_existence, i);
                World_Data[Ycord][Xcord] = 2;
            }
            return(World_Data);
        }