static void Main(string[] args) { Tablero GoL = new Tablero(10, 5); GoL.inserta(new Celula(Estado.viva, GoL, 3, 3)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 2)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 1)); GoL.inserta(new Celula(Estado.viva, GoL, 0, 0)); //GoL.print(); //actualizar el estado_siguiente de todas las celulas //actualizar el estado_actual con el siguiente //volver a imprimir //repetir haciendo una pausa /* GoL.actualiza_estado_todas(); * GoL.print(); * Console.WriteLine("------------------"); * GoL.estado_dos(); * * * //Console.WriteLine(GoL.grid[1][1].num_vecinas()); * GoL.print(); * Console.WriteLine("Empieza el ciclo for"); * GoL.imprime(); * GoL.print(); */ int op; Console.WriteLine("1.-Mostrar el estado inicial."); Console.WriteLine("\n2.-Mostrar el estado siguiente."); Console.WriteLine("\n3.-Mostrar con ciclo for."); Console.WriteLine("\n4.-Salir."); op = Convert.ToInt16(Console.ReadLine()); switch (op) { case 1: GoL.actualiza_estado_todas(); GoL.print(); break; case 2: GoL.estado_dos(); GoL.print(); break; case 3: GoL.imprime(); GoL.print(); break; case 4: Console.WriteLine("Usted decidio salir"); break; default: Console.WriteLine("opcion erronea"); break; } }
static void Main(string[] args) { Tablero GoL = new Tablero(10, 5); GoL.inserta(new Celula(Estado.viva, GoL, 3, 3)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 2)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 1)); GoL.inserta(new Celula(Estado.viva, GoL, 0, 0)); GoL.print(); Console.WriteLine(GoL.grid[1][1].num_vecinas()); }
static void Main(string[] args) { Tablero GoL = new Tablero(10, 5); GoL.inserta(new Celula(Estado.viva, GoL, 3, 3)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 2)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 1)); GoL.inserta(new Celula(Estado.viva, GoL, 0, 0)); int CaseSwitch; do { Console.WriteLine("1.Pocision inicial \n2.Inicializar etapas\n3.Finalizar"); CaseSwitch = Convert.ToInt16(Console.ReadLine()); switch (CaseSwitch) { case 1: GoL.print(); GoL.actualiza_estado_todas(); Console.WriteLine(GoL.grid[1][1].num_vecinas()); break; case 2: for (int i = 0; i < 5; i++) { GoL.print(); GoL.actualiza_estado_todas(); GoL.Avance_turno(); System.Threading.Thread.Sleep(350); } break; case 3: Console.WriteLine("Finalizado"); break; } }while(CaseSwitch != 3); //Actualizar el estado de todas las celdas //Cambiar el estado actual //Volver a imprimir //Repetir haciendo una pausa }
static void Main(string[] args) { Tablero GoL = new Tablero(10, 5); GoL.inserta(new Celula(Estado.viva, GoL, 3, 3)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 2)); GoL.inserta(new Celula(Estado.viva, GoL, 3, 1)); GoL.inserta(new Celula(Estado.viva, GoL, 0, 0)); GoL.print(); // Actualizar el estado_siguiente de todas las celulas // Actualizar el estado actual con el siguiente // Volver a imprimir // Repetir haciendo una pausa }
static void Main(string[] args) { /* * // Glider Gun, hacer tablero de 15, 40 * short[,] glider_gun = new short[,] { * {0, 24}, * {1, 22}, {1, 24}, * {2, 12}, {2, 13}, {2, 20}, {2, 21}, {2, 34}, {2, 35}, * {3,11}, {3,15}, {3,20}, {3,21}, {3,34}, {3,35}, * {4,0}, {4,1}, {4,10}, {4,16}, {4,20}, {4,21}, * {5,0}, {5,1}, {5,10}, {5,14}, {5,16}, {5,17}, {5,22}, {5, 24}, * {6,10}, {6,16}, {6,24}, * {7,11}, {7,15}, * {8,12}, {8,13} * }; */ Tablero GoL = new Tablero(10, 5); GoL.inserta_mapa(new short[, ] { { 3, 3 }, { 3, 2 }, { 3, 1 }, { 0, 0 } }); int input = 1; while (input == 1) { Console.Clear(); Console.WriteLine("Tablero de juego:\n"); GoL.print(); Console.WriteLine("Menu de opciones\n 1.- Siguiente Turno\n 2.- Modificar tablero\n 3.- Adeltantar 50 turnos"); input = int.Parse(Console.ReadLine()); if (input == 1) { GoL.actualizar_tablero(); GoL.siguiente_turno(); } else if (input == 2) { Console.Clear(); GoL.print(true); Console.WriteLine("(Recuerda que los renglones y columnas empiezan de 0)"); InvalidPos: Console.Write("Ingrese las posiciones de la celula en formato '(R)englon,(C)olumna,viva': "); var pos = Console.ReadLine().Split(","); if (pos.Length != 3) { Console.WriteLine("Deben ser 3 parametros en formato '(R)englon,(C)olumna,viva', ejemplo: 0,1,1"); goto InvalidPos; } else { short x = short.Parse(pos[0]); short y = short.Parse(pos[1]); string estado = pos[2]; if (!(x >= 0 && x < GoL.num_renglones)) { Console.WriteLine("El renglon especificado esta fuera de los alcances del tablero.\n"); goto InvalidPos; } else if (!(y >= 0 && y < GoL.num_columnas)) { Console.WriteLine("El renglon especificado esta fuera de los alcances del tablero.\n"); goto InvalidPos; } else if (estado != "1" && estado != "0" && estado != "false" && estado != "true") { Console.WriteLine("El parametro 'viva' tiene que ser true/false, o 0/1.\n"); goto InvalidPos; } else { input = 1; bool viva = false; if (estado == "1" || estado == "true") { viva = true; } GoL.inserta(new Celula((viva ? Estado.viva : Estado.vacia), GoL, x, y)); } } } else if (input == 3) { // 50 Turnos cada 150 ticks (0.150 segundos o 150 milisegundos) GoL.avanzar_turnos(50, 150); input = 1; } } Console.WriteLine("Gracias por jugar el 'Juego de la Vida'"); }