示例#1
0
def guess():
    voted = False
    if request.method == 'POST':
        inst = Instance.from_form(request.form)
        log_vote(inst)
        voted = True
    inst = Instance.gen_random(CODENAMER.wordlist, counts=RANDOM_GUESS_COUNTS)
    CODENAMER.create_hints(inst, n=TOP_GUESS)
    cols = inst.hint_cols()
    name = gin.query_parameter('Codenamer.name')
    # Shuffle columns keeping BAD first
    perm = list(range(len(cols)))
    p1 = perm[1:]
    random.shuffle(p1)
    perm[1:] = p1
    return render_template("guess.html", inst=inst, name=name, perm=perm, cols=cols, voted=voted, nick=inst.nickname)
示例#2
0
def hints():
    inst = Instance()
    voted = False
    if request.method == 'POST':
        inst = Instance.from_form(request.form)
        if 'b_random' in request.form:
            inst = Instance.gen_random(CODENAMER.wordlist, counts=RANDOM_COUNTS)
        if 'b_given' in request.form or 'b_random' in request.form:
            CODENAMER.create_hints(inst, n=TOP)
            inst.hints.insert(0, Hint("", 0.0))
            pass
        elif 'b_vote' in request.form:
            log_vote(inst)
            voted = True
            pass
        else:
            raise Exception('Unknown button in POST')
    cols = inst.hint_cols()
    name = gin.query_parameter('Codenamer.name')
    return render_template("hints.html", inst=inst, name=name, cols=cols, voted=voted, nick=inst.nickname)