def main():
    t, _, _, puzzles, starter_words, all_puzzle_keys = get_input()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)

    search(dic, puzzles, all_puzzle_keys, t, starter_words)
def main():
    found_words = []
    words_value = 0

    search_range = 2
    fail_counter = 0
    MAX_FAILS = 20

    t, n, s, puzzles, possibile_solutions, all_puzzle_keys = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)

    max_len = len(all_puzzle_keys)
    population = init_population(dic, puzzles, 100, all_puzzle_keys,
                                 search_range)

    while check_time(start_time, t) or True:
        prev_value = words_value
        words_value += search_for_words(found_words, population, dic, puzzles,
                                        search_range)
        if prev_value == words_value and search_range < max_len:
            fail_counter += 1
            if fail_counter == MAX_FAILS * search_range // 2:
                search_range += 1
                population = init_population(dic, puzzles, 100,
                                             all_puzzle_keys, search_range)
                fail_counter = 0
        else:
            fail_counter = 0

        population.recombinate()
        population.mutate()
        print(words_value, int(time.time() - start_time), search_range)
Exemplo n.º 3
0
def main():
    t, n, s, puzzles, possibile_solutions, all_puzzle_keys = get_input()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)

    search(dic, puzzles, all_puzzle_keys, t)
def main():
    found_words = []
    words_value = 0

    search_range = 3
    fail_counter = 0
    MAX_FAILS = 20

    t, n, s, puzzles, possibile_solutions = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        max_len = dic.load(f)

    population = init_population(dic,
                                 puzzles,
                                 1000,
                                 inhabitant_start_size=max_len)

    while check_time(start_time, t) or True:
        prev_value = words_value
        words_value += search_for_words(found_words, population, dic, puzzles,
                                        search_range)
        if prev_value == words_value:
            fail_counter += 1
            if fail_counter == MAX_FAILS:
                search_range += 1
                fail_counter = 0
        else:
            fail_counter = 0

        population.recombinate()
        population.mutate()
        print(words_value)
Exemplo n.º 5
0
def main():
    found_words = []
    words_value = 0

    t, n, s, puzzles, possibile_solutions, all_puzzle_keys = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)

    search()
Exemplo n.º 6
0
def main():
    found_words = []
    words_value = 0

    search_range = 2
    fail_counter = 0
    MAX_FAILS = 25

    t, n, s, puzzles, possibile_solutions, all_puzzle_keys = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)
Exemplo n.º 7
0
def main():
    found_words = []
    words_value = 0
    t, n, s, puzzles, possibile_solutions = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        max_len = dic.load(f)

    population = init_population(dic, puzzles, inhabitant_start_size=max_len)

    while check_time(start_time, t) or True:
        words_value += search_for_words(found_words, population, dic, puzzles,
                                        max_len)
        population.mutate()
        print(words_value)
def main():
    found_words = []
    words_value = 0

    t, n, s, puzzles, possibile_solutions, all_puzzle_keys = get_input()
    start_time = time.time()
    dic = HmapStructure()
    with open('z2/dict.txt') as f:
        dic.load(f)

    population = init_population(dic, puzzles, 100, all_puzzle_keys)

    while check_time(start_time, t) or True:
        prev_value = words_value
        words_value += search_for_words(found_words, population, dic, puzzles,
                                        max_len)

        population.recombinate()
        population.mutate()
        print(words_value, int(time.time() - start_time))