Exemplo n.º 1
0
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)
Exemplo n.º 2
0
def decision():
    # Get id of winner and loser
    # Compute elo score change of winner and loser
    # Modify scores in db
    # If we are at the end of current gen, do all the evolution stuff
    # Redirect back to the homepage with 2 new individuals
    form = request.form
    generation = int(request.form['generation'])
    if generation != len(Database.get_historical_individuals()):
        return 'ignored'
    winner_id = request.form['winner'] # string
    loser_id = request.form['loser'] # string

    modify_scores(winner_id, loser_id)
    save_decision(winner_id, loser_id)
    end_generation()

    return 'ok'
Exemplo n.º 3
0
def get_history():
    return Database.get_historical_individuals()