Пример #1
0
def test6(conn, limite):
    """
    Test movimiento aleatorio total con dos individuos moviendose con memoria
    """
    tipo = "test6"
    # Situamos a los individuos inicialmente
    a = Individuo(random.randrange(1, borde), random.randrange(1, borde), borde)
    b = Individuo(random.randrange(1, borde), random.randrange(1, borde), borde)

    t1 = Tablero()
    t2 = Tablero()

    # Bucle de busqueda
    exito = False
    while exito == False:

        a.x, a.y = t1.dameCasilla()
        b.x, b.y = t2.dameCasilla()

        if a.x == -1 or b.x == -1:
            break

        a.movimientos += 1
        b.movimientos += 1

        if a.movimientos >= limite:
            break
        if b.movimientos >= limite:
            break

        if a.x == b.x and a.y == b.y:  # Si estan en la misma casilla... exito
            exito = True

    print tipo, ":", a.movimientos
    escribeEnDB(conn, tipo, a.movimientos, b.movimientos, exito)