def begin_interact():
    p = bot_manager.load_bot()
    p['count'] += 1
    bot_manager.save_bot(p)
    mult = ((p['anger']+p['hostility'])/2)
    return dumps(dict(call='begin_interact',
                      mult=mult,
                      hostility=p['hostility']))
def trade_interact():
    p = bot_manager.load_bot()
    action, p_new = trade_decider.trade(p)
    mult = 0
    bot_manager.save_bot(p_new)
    if action == 'fight':
        mult = ((p['anger']+p['hostility'])/2)
    return dumps(dict(action=action,
                      mult=mult, 
                      call='trade_interact',
                      hostility=p['hostility']))
def talk_interact():
    sentence = request.json['sentence']
    p = bot_manager.load_bot()
    p['sentence'] = sentence
    p_new = talk_decider.main(p)
    bot_manager.save_bot(p_new)
    action, mult = fight_decider.action(p)
    return dumps(dict(call='talk_interact',
                      action=action, 
                      mult=mult, 
                      hostility=p['hostility']))
def fight_interact():
    p = bot_manager.load_bot()
    action, mult = 'run', ((p['anger']+p['hostility'])/2)
    if mult > PARAMS['avg_fight'] or p['hostility'] > .9:
        action = 'fight'
    else:
        p['hostility'] = min(.99, p['hostility'] + .2)
        bot_manager.save_bot(p)
    return dumps(dict(call='fight_interact',
                      action=action,
                      mult=mult, 
                      hostility=p['hostility']))
def run_interact():
    p = bot_manager.load_bot()
    action, h_delta = run_decider.main(p)
    p['hostility'] += h_delta
    bot_manager.save_bot(p)
    mult = 0
    if action == 'fight':
        mult = ((p['anger']+p['hostility'])/2)
    return dumps(dict(call='run_interact',
                      action=action, 
                      mult=mult, 
                      hostility=p['hostility']))