Exemplo n.º 1
0
        public Partida SiguienteMovimiento(Partida juego)
        {
            int    fila    = -1;
            int    columna = -1;
            Random random  = new Random();
            Ficha  ficha   = Ficha.NINGUNA;

            do
            {
                Console.Write("\nIndique Posicion [fila,columna]");
                string entrada = Console.ReadLine();
                var    split   = entrada.Split(",");
                if (int.TryParse(split[0], out fila) && int.TryParse(split[1], out columna))
                {
                    ficha = juego.Valor(fila, columna);
                }
            } while (ficha != Ficha.NINGUNA);

            juego.Estado = Progreso.PROGRESO;
            if (juego.Turno == Turno.JUGADOR1)
            {
                juego.Tablero[fila, columna] = Ficha.JUGADOR1;
                juego.Turno = Turno.JUGADOR2;
            }
            else
            {
                juego.Tablero[fila, columna] = Ficha.JUGADOR2;
                juego.Turno = Turno.JUGADOR1;
            }


            return(juego);
        }
Exemplo n.º 2
0
        public Partida SiguienteMovimiento(Partida juego)
        {
            int    filaRandom;
            int    columnaRandom;
            Random random = new Random();
            Ficha  ficha;

            do
            {
                filaRandom    = random.Next(0, juego.Rango);
                columnaRandom = random.Next(0, juego.Rango);
                ficha         = juego.Valor(filaRandom, columnaRandom);
            } while (ficha != Ficha.NINGUNA);

            juego.Estado = Progreso.PROGRESO;
            if (juego.Turno == Turno.JUGADOR1)
            {
                juego.Tablero[filaRandom, columnaRandom] = Ficha.JUGADOR1;
                juego.Turno = Turno.JUGADOR2;
            }
            else
            {
                juego.Tablero[filaRandom, columnaRandom] = Ficha.JUGADOR2;
                juego.Turno = Turno.JUGADOR1;
            }


            return(juego);
        }