Пример #1
0
def dijkstra():
    global filename_input
    ok = False
    while not ok:
        filename_input = call_generate()
        if filename_input is not None:
            ok = True

    path_output = raw_input("Dove salvare il file di output? ")
    path_output = path_output if path_output[-1] == "/" else path_output + "/"

    matches = make_matches(filename_input)
 
    start = time()
    outs = []
    for match in matches:
        match.makeGraph()
	m = match.minMovesDijkstra()
	if str(m) == 'inf':
           m = 'impossibile'
	outs.append(str(m))
    print "\nAlgoritmo eseguito: Dijkstra sul grafo delle mosse"
    print "Tempo d'esecuzione:", time() - start, "secondi\n"
    generate_file(1, outs, path_output)
    raise SystemExit()
Пример #2
0
def call_maometto():
    maometto_menu()
    global filename_input
    ok = False
    while not ok:
        filename_input = call_generate()
        if filename_input is not None:
            ok = True

    path_output = raw_input("Dove salvare il file di output? ")
    path_output = path_output if path_output[-1] == "/" else path_output + "/"

    print("")
    print("-------------------------------------------------------------------")
    print("             TARGET della DISTRIBUZIONE - ISTRUZIONI               ")
    print("-------------------------------------------------------------------")
    print("\nCome spiegato nella relazione abbiamo implementato piu'\n"
	     "generatori di targetes. Quale generatore di targets usare?\n"
	     "(0 per avere un solo target, 1 per avere target con un intorno\n"
	     "di 1 casella (default), 2 per avere con un intorno di 2 caselle,\n"
	     "3 per avere target con target e le posizioni dei cavalli e \n"
	     "4 per avere tutta la scacchiera\n")
    type = int(raw_input("Inserire una tipologia di target: "))
    if type < 0 or type > 4:
        type = 1
	print("Abbiamo scelto per te il generatore di default!\n")
    
    matches = make_matches(filename_input)

    start = time()
    outs = []
    for match in matches:
        montagna(match, int(type), outs, False)
    print "\nAlgoritmo eseguito: Montagna"
    print "Tempo d'esecuzione:", time() - start, "secondi\n"
    generate_file(1, outs, path_output)
    raise SystemExit()