Esempio n. 1
0
File: ui.py Progetto: huberth/4d
    def main_loop(self):
        input.read_input()

        # draw each layer, bottom to top
        self.surface.fill(pygame.Color(0,0,0))
        for screen in self.stack:
            screen.draw(self.surface)
        
        # however, only update the top surface with input
        result = self.stack[-1].update(input.last_frame)
        if not result:
            self.stack.pop()

        clock.tick(fps)

        pygame.display.flip()
Esempio n. 2
0
def main():
    # input_file = 'b_lovely_landscapes.txt'
    # input_file = 'c_memorable_moments.txt'
    input_file = 'd_pet_pictures.txt'
    # input_file = 'e_shiny_selfies.txt'
    P, v, h = read_input('inputs/' + input_file)

    v_count = len(v)
    h_count = len(h)

    print(P)
    print(v_count)
    print(h_count)

    slideshow = []
    max_score = 0
    max_score_slideshow = []
    start = time.time()
    idx = 0
    while time.time() - start < 60:
        idx += 1
        repeatRandomness(slideshow, h, v, P)
        if idx % 5000 == 0:
            score = scoreArray(slideshow)
            print('\r', score, '/', max_score, ' - ', len(slideshow), end="")
            if score > max_score:
                max_score = score
                max_score_slideshow = slideshow

    write_output('outputs/' + input_file, max_score_slideshow)
Esempio n. 3
0
File: main.py Progetto: tiane33/Maze
def run_stuff(infile, outfile, parameters="params.txt", outformat="delim"):
    """Takes an input file, and an output file location
    Does the whole distractor thing (according to specified parameters)
    Writes in outformat"""
    if outformat not in ["delim", "ibex"]:
        logging.error("outfile format not understood")
        raise ValueError
    params = set_params(parameters)
    sents = read_input(infile)
    dict_class = getattr(
        importlib.import_module(
            params.get("dictionary_loc", "wordfreq_distractor")),
        params.get("dictionary_class", "wordfreq_English_dict"))
    d = dict_class(params)
    model_class = getattr(
        importlib.import_module(params.get("model_loc", "gulordava")),
        params.get("model_class", "gulordava_model"))
    m = model_class()
    threshold_func = getattr(
        importlib.import_module(
            params.get("threshold_loc", "wordfreq_distractor")),
        params.get("threshold_name", "get_thresholds"))
    for ss in sents.values():
        ss.do_model(m)
        ss.do_surprisals(m)
        ss.make_labels()
        ss.do_distractors(m, d, threshold_func, params)
        ss.clean_up()
    if outformat == "delim":
        save_delim(outfile, sents)
    else:
        save_ibex(outfile, sents)
Esempio n. 4
0
def main():
    video_sizes, latencies_to_dc, latencies_to_cs, requests, (
        V, E, R, C, X) = read_input("example.in")
    print(video_sizes)
    print(latencies_to_dc)
    print(latencies_to_cs)
    print(requests)
Esempio n. 5
0
def score(file):
  score = 0;
  video_sizes, latencies_to_dc, latencies_to_cs, requests, (V, E, R, C, X) = read_input("example.in")
  file = open("output/" + file, "r")
  num_cs = int(file.readline())
  
  for i in range(num_cs):
    cs_id, v_ids = file.readline().split(" ")
Esempio n. 6
0
def main():
    parser = ArgumentParser()
    parser.add_argument("file", type=str, help="the text file database")
    parser.add_argument("person",
                        type=str,
                        help="the person to make the family tree for")
    args = parser.parse_args()

    fam = read_input(args.file)

    output_file = "fam"
    write_output(fam, fam[args.person], output_file)
    system("inkscape {0}.svg --export-pdf {0}.pdf".format(output_file))
Esempio n. 7
0
def get_input_and_run(history_file_path, user_input, set_variables, flag):
    """
    Get input from user, turn it into runable command
    then run the command

    @param history_file_path: path to the history file
    @param user_input: user's input
    @param set_variables: shell variables
    @param flag: boolean, check if command is valid for saving to history
    """
    # get input
    if user_input:
        user_input = ' '.join(user_input)
    else:
        user_input = read_input()
    # turn raw input to readable command
    user_input = handle_input(user_input, set_variables, history_file_path,
                              flag)
    # run command
    run_logical_operator(user_input, set_variables)
Esempio n. 8
0
def init_config():
    logging.info('config.json was not found. generate a new config file')
    setting_data = {}
    setting_data['db'] = read_input('db name')
    write_config(setting_data)
    return setting_data
Esempio n. 9
0
def run(input_path, output_path):
    nr_dict, pizzas = input.read_input(input_path)
    deliveries = solver.solve(nr_dict, pizzas)
    output.create_output_file(output_path, deliveries)
Esempio n. 10
0
 def get_or_input(self, key, input_name, expected_type=type('')):
     my_data = self.get(key)
     if not my_data:
         my_data = str(read_input(input_name, expected_type))
         self.set(key, my_data)
     return my_data
# get_ipython().magic('reset -sf')

# IMPORT MODULES
import genes
import input
import fitness01
import selection
import crossover
import mutation
import output
import find_minmax
import global_fitness_normalization
import migration

### READ THE INPUTS FROM FILE AND APPEND THEM TO THE VARIABLES
girdi = input.read_input()

iteration = int(girdi[7])
number_of_bits = int(girdi[10])
population_size = int(girdi[11])
number_of_genes = int(girdi[12])
mutation_probability = float(girdi[3])
saved_data = int(girdi[8])
objective_number = int(girdi[15])
migration_probability = float(girdi[6])
selection_type = int(girdi[13])
cross_over_probability = float(girdi[2])
crossover_type = int(girdi[14])  ## one-point / two-point

lower_boundary_index = 17
upper_boundary_index = lower_boundary_index + number_of_genes
Esempio n. 12
0
transport.connect(server_ip, frame_time())

while 1:
    socket.update()

    set_frame()

    game_info = transport.get_game_info(frame_time())
    if game_info != None: break
    local_input()

init_input()
init_output(game_info.width, game_info.height)

last_frame = 0
frame_length = 10

while 1:
    socket.update()

    set_frame()
    dt = frame_time() - last_frame
    if dt < frame_length: continue
    last_frame = frame_time()

    character_input = read_input()
    transport.send_input(character_input)

    game_state = transport.get_game_state()
    update_screen(game_info, game_state)