Beispiel #1
0
def test_AEstrela():
    state = PlusOneTwo(1, '', 10)
    inicio = datetime.now()
    algorithm = AEstrela()
    fim = datetime.now()
    print(fim - inicio)
    result = algorithm.search(state)
    assert result.show_path() == " ; 2 ; 2 ; 2 ; 2 ; 1"
Beispiel #2
0
def test_largura_bigger_AEstrela():
    state = PlusOneTwo(1, '', 501)
    algorithm = AEstrela()
    inicio = datetime.now()
    result = algorithm.search(state)
    fim = datetime.now()
    print(fim - inicio)
    print(result.show_path())
Beispiel #3
0
def test_AEstrela2():
    print('Busca por algoritmo A*: sair de Orgrimmar e chegar em Stormwind')
    state = WorldWarcraftMap('Orgrimmar', 0, 'Orgrimmar', 'Stormwind')
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    print('Tempo de processamento em segundos: ' + str(tf - ts))
    print('O custo da solucao eh: ' + str(result.g))
    assert result.show_path() == "Orgrimmar ; Kezan ; Stormwind"
Beispiel #4
0
def test_AEstrela2():
    print('Busca por algoritmo A*: sair de i e chegar em x')
    state = Map('i', 0, 'i', 'x')
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    print('Tempo de processamento em segundos: ' + str(tf - ts))
    print('O custo da solucao eh: ' + str(result.g))
    assert result.show_path() == "i ; h ; k ; n ; m ; x"
Beispiel #5
0
def main():
    print('Busca A *')
    state = TaxiDriver([0, 0], False, '')
    algorithm = AEstrela()
    result = algorithm.search(state)
    if result != None:
        print('Achou!')
        print(result.show_path() + " ; drop passanger")
    else:
        print('Nao achou solucao')
Beispiel #6
0
def test_AEstrela():
    print('Busca por algoritmo A*: sair de Ahn Qiraj e chegar em Silvermoon')
    state = WorldWarcraftMap('Ahn Qiraj', 0, 'Ahn Qiraj', 'Silvermoon')
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    print('Tempo de processamento em segundos: ' + str(tf - ts))
    print('O custo da solucao eh: ' + str(result.g))
    assert result.show_path(
    ) == "Ahn Qiraj ; Gadgetzan ; Gurubashi Arena ; Gnomeregan ; Stormwind ; Kezan ; Orgrimmar ; Silvermoon"
Beispiel #7
0
def test_AEstrela3():
    print('Busca por algoritmo A*: sair de Undercity e chegar em Darnassus')
    state = WorldWarcraftMap('Undercity', 0, 'Undercity', 'Darnassus')
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    print('Tempo de processamento em segundos: ' + str(tf - ts))
    print('O custo da solucao eh: ' + str(result.g))
    assert result.show_path(
    ) == "Undercity ; Orgrimmar ; Thunder Bluff ; Darnassus"
Beispiel #8
0
def main():
    WorldWarcraftMap.createArea()
    WorldWarcraftMap.createHeuristics()

    start = 'Ahn Qiraj'
    end = 'Silvermoon'
    print('\nBusca por algoritmo A* (de {} a {}):\n'.format(start, end))
    state = WorldWarcraftMap(start, 0, start, end)
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    if result != None:
        print(result.show_path())
        print('\nCusto total da solução: '+str(result.g))
    else:
        print('Não achou solução')
    print('Tempo de processamento em segundos: {}\n'.format(str(tf-ts)))
Beispiel #9
0
def main():

    Map.createArea()
    Map.createHeuristics()

    print('Busca por algoritmo A*: sair de p e chegar em n')
    state = Map('i', 0, 'i', 'x')
    algorithm = AEstrela()
    ts = time.time()
    result = algorithm.search(state)
    tf = time.time()
    if result != None:
        print(result.show_path())
    else:
        print('Nao achou solucao')
    print('Tempo de processamento em segundos: ' + str(tf - ts))
    print('O custo da solucao eh: ' + str(result.g))
    print('')