예제 #1
0
        public Coordenada realizarMovimiento()
        {
            // esta estrategia siempre genera un aleatorio, no le interesan los movimientos anteriores.
            int        x = (int)Math.Round(distribucion.generar(), 0);
            int        y = (int)Math.Round(distribucion.generar(), 0);
            Coordenada c = new Coordenada(x, y);

            return(c);
        }
예제 #2
0
        // para posicionar el barco.
        public Coordenada obtenerCoordenada()
        {
            if (generadorCoordenadas == null)
            {
                generadorCoordenadas    = new CongruencialMixto(seed, a, c, m);
                distribucionCoordenadas = new DistribucionUniforme(0, 63, generadorCoordenadas);
            }
            int        _x    = (int)Math.Round(distribucionCoordenadas.generar(), 0);
            int        _y    = (int)Math.Round(distribucionCoordenadas.generar(), 0);
            Coordenada coord = new Coordenada(_x, _y);

            return(coord);
        }
예제 #3
0
        public int obtenerSentido()
        {
            int retorno = 0;

            if (generadorSentidos == null)
            {
                generadorSentidos    = new CongruencialMixto(seed, a, c, m);
                distribucionSentidos = new DistribucionUniforme(1, 4, generadorSentidos);
            }
            retorno = Convert.ToInt32(distribucionSentidos.generar());
            return(retorno);
        }
        public Coordenada realizarMovimiento()
        {
            int        x = 0;
            int        y = 0;
            Coordenada c = new Coordenada(x, y);

            if (ultMovAcertado == null)
            {
                if (cant_repetidos >= 2000)
                {
                    if (origen.y < 62)
                    {
                        origen.y = origen.y + 2;
                    }
                    else
                    {
                        if (origen.x < 62)
                        {
                            origen.x = origen.x + 2;
                            if (bpar == true)
                            {
                                origen.y = 0;
                            }
                            else
                            {
                                origen.y = 1;
                            }
                        }
                        else
                        {
                            origen.x = 1;
                            origen.y = 1;
                            bpar     = false;
                        }
                    }
                    c = origen;
                    return(c);
                }
                else
                {
                    x   = (int)Math.Round(distribucion.generar(), 0);
                    y   = (int)Math.Round(distribucion.generar(), 0);
                    c.x = x;
                    c.y = y;
                    return(c);
                }
            }
            else
            {// arriba = 1 derecha = 2 abajo = 3 izquierda = 4
                if (ultimo_desplazamiento_acertado != 0)
                {
                    if (ultimoResultado == 0 || ultimoResultado == -1)
                    {
                        ultMovAcertado = primerMov;
                        if (ultimo_desplazamiento_acertado < 4)
                        {
                            ultimo_desplazamiento = ultimo_desplazamiento_acertado + 1;
                        }
                        else
                        {
                            ultimo_desplazamiento = 1;
                        }
                    }
                    else
                    {
                        ultimo_desplazamiento = ultimo_desplazamiento_acertado - 1;
                    }
                }
                ultimo_desplazamiento = validarFinGrilla();
                switch (ultimo_desplazamiento)
                {
                case 0:
                    x   = ultMovAcertado.x - 1;
                    y   = ultMovAcertado.y;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 1;
                    break;

                case 1:
                    x   = ultMovAcertado.x;
                    y   = ultMovAcertado.y + 1;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 2;
                    break;

                case 2:
                    x   = ultMovAcertado.x + 1;
                    y   = ultMovAcertado.y;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 3;
                    break;

                case 3:
                    x   = ultMovAcertado.x;
                    y   = ultMovAcertado.y - 1;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 4;
                    break;
                }
                return(c);
            }
        }
예제 #5
0
        public Coordenada realizarMovimiento()
        {
            // esta estrategia siempre genera un aleatorio, no le interesan los movimientos anteriores.
            int        x = 0;
            int        y = 0;
            Coordenada c = new Coordenada(x, y);

            if (ultMovAcertado == null)
            {
                //if (cant_repetidos >= 2000)
                //{
                //    if (origen.y < 62)
                //    {
                //        origen.y = origen.y + 2;
                //    }
                //    else
                //    {
                //        if (origen.x < 62)
                //        {
                //            origen.x = origen.x + 2;
                //            if (bpar == true)
                //            {
                //                origen.y = 0;
                //            }
                //            else
                //            {
                //                origen.y = 1;
                //            }

                //        }
                //        else
                //        {
                //            origen.x = 1;
                //            origen.y = 1;
                //            bpar = false;
                //        }
                //    }
                //    c = origen;
                //    return c;
                //}
                //else
                //{
                //    x = (int)Math.Round(distribucion.generar(), 0);
                //    y = (int)Math.Round(distribucion.generar(), 0);
                //    c.x = x;
                //    c.y = y;
                //    return c;
                //}
                if (movimiento == null)
                {
                    x = (int)Math.Round(distribucion.generar(), 0);
                    y = (int)Math.Round(distribucion.generar(), 0);
                }
                else
                {
                    if (movimiento.x == 63 || movimiento.y == 63)
                    {
                        x = (int)Math.Round(distribucion.generar(), 0);
                        y = (int)Math.Round(distribucion.generar(), 0);
                    }
                    else
                    {
                        x = movimiento.x + 1;
                        y = movimiento.y + 1;
                    }
                }
                c.x        = x;
                c.y        = y;
                movimiento = c;
                return(c);
            }
            else
            {// arriba = 1 derecha = 2 abajo = 3 izquierda = 4
                if (ultimo_desplazamiento_acertado != 0)
                {
                    if (ultimoResultado == 0 || ultimoResultado == -1)
                    {
                        ultMovAcertado = primerMov;
                        if (ultimo_desplazamiento_acertado < 4)
                        {
                            ultimo_desplazamiento = ultimo_desplazamiento_acertado + 1;
                        }
                        else
                        {
                            ultimo_desplazamiento = 1;
                        }
                    }
                    else
                    {
                        ultimo_desplazamiento = ultimo_desplazamiento_acertado - 1;
                    }
                }
                ultimo_desplazamiento = validarFinGrilla();
                switch (ultimo_desplazamiento)
                {
                case 0:
                    x   = ultMovAcertado.x - 1;
                    y   = ultMovAcertado.y;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 1;
                    break;

                case 1:
                    x   = ultMovAcertado.x;
                    y   = ultMovAcertado.y + 1;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 2;
                    break;

                case 2:
                    x   = ultMovAcertado.x + 1;
                    y   = ultMovAcertado.y;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 3;
                    break;

                case 3:
                    x   = ultMovAcertado.x;
                    y   = ultMovAcertado.y - 1;
                    c.x = x;
                    c.y = y;
                    ultimo_desplazamiento = 4;
                    break;
                }
            }
            return(c);
        }