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()
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)
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)
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)
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(" ")
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))
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)
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
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)
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
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)