def projeto_SaferRoute(): dimensao_da_matriz = 20 lab = Labirinto(dimensao_da_matriz) id = 0 agente = lab.add_pacman(id) origem = agente._posicao destino = lab.fim_aleatorio() lab.desenhar_celula(origem, 'red') lab.desenhar_celula(destino, 'red') intervalo_entre_frames = 0.3 n_fantasmas = myInput.qtd_fantasmas( ) # define a quantidade de fantasmas de acordo com a aglomeração for id in range(1, n_fantasmas): lab.add_fantasma(id) agentes = lab.agentes chegou_ao_destino = False while (not chegou_ao_destino): for id in agentes.keys(): if id != 0: agentes[id].vaguear() #faz os fantasmas vaguearem sleep(intervalo_entre_frames) chegou_ao_destino = agente.ir_a(destino) update()
def agente_com_um_destino(): """ Agente caminha para um destino aleatoriamente sorteado """ dimensao_da_matriz = 20 lab = Labirinto(dimensao_da_matriz) id = 0 agente = lab.add_pacman(id) ghost = lab.add_fantasma(2) origem = agente._posicao destino = lab.fim_aleatorio() lab.desenhar_celula(origem, 'red') lab.desenhar_celula(destino, 'red') intervalo_entre_frames = 0.1 chegou_ao_destino = False while (not chegou_ao_destino): chegou_ao_destino = agente.ir_a(destino) # Atualiza "frame" update() sleep(intervalo_entre_frames)