def index(): # Check table, populate if empty # Show two random individuals in the current gen populate_current_generation_if_empty() a, b = Database.get_random_individuals(2) ar = render_individual(a['parameters']) br = render_individual(b['parameters']) aid, bid = a['id'], b['id'] prg = str(float(Database.num_comparisons()) / Constants.COMPARISONS_PER_GENERATION * 100) gen = len(Database.get_historical_individuals()) magic_color = Database.get_all_individuals_sorted()[0]['parameters']['palette_1'] magic_color = '#%06x' % magic_color return render_template('index.html', left_id=aid, left=ar, right_id=bid, right=br, progress=prg, generation=gen, magic_color=magic_color)
def end_of_generation(): ''' Returns bool whether it is the end of a generation ''' return Database.num_comparisons() >= Constants.COMPARISONS_PER_GENERATION