Exemple #1
0
        public void CambioAleatorio()
        {
            Acciones.Enqueue("Ocurre un Cambio Aleatorio De Ambiente");

            Ocupadas = new bool[N, M];
            Casillas = new Elemento[N, M];
            int corral = PosCorral.Count;
            int sucio  = PosSuciedad.Count;
            int cantN  = PosNiños.Count;

            PosCorral.Clear();
            PosNiños.Clear();
            PosObstaculo.Clear();
            PosSuciedad.Clear();

            foreach (var item in Robots)
            {
                Ocupadas[item.X, item.Y] = true;
                Casillas[item.X, item.Y] = Elemento.Robot;
            }

            Acciones.Enqueue("Reubicando elementos");
            PonerCorral(corral, totalNiños - corral);
            PonerElemento(obstaculos, Elemento.Obstaculo);
            PonerElemento(sucio, Elemento.Suciedad);
            PonerElemento(cantN, Elemento.Niño);
        }
Exemple #2
0
        protected void PonerElemento(int cant, Elemento element)
        {
            int x;
            int y;

            do
            {
                x = Random.Next(0, N);
                y = Random.Next(0, M);

                if (!Ocupadas[x, y])
                {
                    Ocupadas[x, y] = true;
                    Casillas[x, y] = element;

                    switch (element)
                    {
                    case Elemento.Niño:
                    {
                        PosNiños.Add(new Tuple <int, int>(x, y));
                        Acciones.Enqueue("Se ubica niño en la posicion (" + x + "," + y + ")");
                    } break;

                    case Elemento.Suciedad:
                    {
                        PosSuciedad.Add(new Tuple <int, int>(x, y));
                        Acciones.Enqueue("Se crea suciedad en la posicion (" + x + "," + y + ")");
                    }
                    break;

                    case Elemento.Obstaculo:
                    {
                        PosObstaculo.Add(new Tuple <int, int>(x, y));
                        Acciones.Enqueue("Se ubica obstaculo en la posicion (" + x + "," + y + ")");
                    }
                    break;

                    default:
                        break;
                    }
                    cant--;
                }
            } while (cant > 0 && HayEspacio());
        }