예제 #1
0
    def run_hit(hit_index, assignment_index, opt, mturk_manager):
        conversation_id = str(hit_index) + '_' + str(assignment_index)

        # Create mturk agents
        mturk_agent_1 = MTurkAgent(id=mturk_agent_1_id,
                                   manager=mturk_manager,
                                   conversation_id=conversation_id,
                                   opt=opt)
        mturk_agent_2 = MTurkAgent(id=mturk_agent_2_id,
                                   manager=mturk_manager,
                                   conversation_id=conversation_id,
                                   opt=opt)

        # Create the local human agents
        human_agent_1 = LocalHumanAgent(opt=None)
        human_agent_1.id = human_agent_1_id
        human_agent_2 = LocalHumanAgent(opt=None)
        human_agent_2.id = human_agent_2_id

        world = MultiAgentDialogWorld(opt=opt,
                                      agents=[
                                          human_agent_1, human_agent_2,
                                          mturk_agent_1, mturk_agent_2
                                      ])

        while not world.episode_done():
            world.parley()
        world.shutdown()
예제 #2
0
파일: run.py 프로젝트: analyticlaks/ParlAI
    def run_hit(hit_index, assignment_index, opt, mturk_manager):
        conversation_id = str(hit_index) + '_' + str(assignment_index)

        # Create mturk agents
        mturk_agent_1 = MTurkAgent(id=mturk_agent_1_id, manager=mturk_manager, conversation_id=conversation_id, opt=opt)
        mturk_agent_2 = MTurkAgent(id=mturk_agent_2_id, manager=mturk_manager, conversation_id=conversation_id, opt=opt)

        # Create the local human agents
        human_agent_1 = LocalHumanAgent(opt=None)
        human_agent_1.id = human_agent_1_id
        human_agent_2 = LocalHumanAgent(opt=None)
        human_agent_2.id = human_agent_2_id

        world = MultiAgentDialogWorld(opt=opt, agents=[human_agent_1, human_agent_2, mturk_agent_1, mturk_agent_2])

        while not world.episode_done():
            world.parley()
        world.shutdown()
예제 #3
0
파일: run.py 프로젝트: janoschhaber/psivgd
def main():
    """
    Main function for the DMG pilot data collection task
    :return: Nothing.
    """
    argparser = ParlaiParser(False, False)
    argparser.add_parlai_data_path()

    opt = argparser.parse_args()
    opt['task'] = 'dmg_pilot_dev'
    opt['datatype'] = 'dmg_pilot_data_1'
    opt.update(task_config)

    local_agent_1 = LocalHumanAgent(opt=None)
    local_agent_1.id = 'A'
    local_agent_2 = LocalHumanAgent(opt=None)
    local_agent_2.id = 'B'

    agents = [local_agent_1, local_agent_2]

    world = LocalDMGDialogWorld(opt=opt, agents=agents)

    # Loop over all five rounds of the game
    for r in range(5):
        print("--- Starting round {} ---".format(r + 1))
        while not world.episode_done():
            world.parley()

        # Write the log data to file
        with open('logs/dmg_pilot_data_{}.json'.format(world.game_nr),
                  'w') as f:
            json.dump(world.conversation_log, f)

        # Reset the world for the next round
        world.round_log['data'] = []
        world.round_log['score'] = None
        world.selections = defaultdict(lambda: dict())
        world.turn_nr = -1
        world.round_nr += 1
        world.episodeDone = False

    world.shutdown()
예제 #4
0
파일: run.py 프로젝트: calee88/ParlAI
def main():
    argparser = ParlaiParser(False, False)
    argparser.add_parlai_data_path()
    argparser.add_mturk_args()
    opt = argparser.parse_args()
    opt['task'] = os.path.basename(os.getcwd())

    mturk_agent_1_id = 'mturk_agent_1'
    mturk_agent_2_id = 'mturk_agent_2'
    human_agent_1_id = 'human_1'
    human_agent_2_id = 'human_2'

    # Create the MTurk agents
    opt.update(task_config)
    opt['conversation_id'] = str(int(time.time()))

    opt['mturk_agent_ids'] = [mturk_agent_1_id, mturk_agent_2_id]
    opt['all_agent_ids'] = [
        human_agent_1_id, human_agent_2_id, mturk_agent_1_id, mturk_agent_2_id
    ]

    opt['agent_id'] = mturk_agent_1_id
    mturk_agent_1 = MTurkAgent(opt=opt)

    opt['agent_id'] = mturk_agent_2_id
    mturk_agent_2 = MTurkAgent(opt=opt)

    # Create the local human agents
    human_agent_1 = LocalHumanAgent(opt=None)
    human_agent_1.id = human_agent_1_id
    human_agent_2 = LocalHumanAgent(opt=None)
    human_agent_2.id = human_agent_2_id

    world = MultiAgentDialogWorld(
        opt=opt,
        agents=[human_agent_1, human_agent_2, mturk_agent_1, mturk_agent_2])

    while not world.episode_done():
        world.parley()

    world.shutdown()
예제 #5
0
    def run_hit(i, opt):
        opt['conversation_id'] = str(i)

        opt['agent_id'] = opt['mturk_agent_1_id']
        mturk_agent_1 = MTurkAgent(opt=opt)
        opt['agent_id'] = opt['mturk_agent_2_id']
        mturk_agent_2 = MTurkAgent(opt=opt)

        # Create the local human agents
        human_agent_1 = LocalHumanAgent(opt=None)
        human_agent_1.id = opt['human_agent_1_id']
        human_agent_2 = LocalHumanAgent(opt=None)
        human_agent_2.id = opt['human_agent_2_id']

        world = MultiAgentDialogWorld(opt=opt,
                                      agents=[
                                          human_agent_1, human_agent_2,
                                          mturk_agent_1, mturk_agent_2
                                      ])
        while not world.episode_done():
            world.parley()
        world.shutdown()
예제 #6
0
파일: run.py 프로젝트: rapalizsolt/ParlAI
    def run_hit(i, opt, mturk_manager):
        # Create mturk agents
        mturk_agent_1 = MTurkAgent(id='mturk_agent_1',
                                   manager=mturk_manager,
                                   conversation_id=i,
                                   opt=opt)
        mturk_agent_2 = MTurkAgent(id='mturk_agent_2',
                                   manager=mturk_manager,
                                   conversation_id=i,
                                   opt=opt)

        # Create the local human agents
        human_agent_1 = LocalHumanAgent(opt=None)
        human_agent_1.id = 'human_1'
        human_agent_2 = LocalHumanAgent(opt=None)
        human_agent_2.id = 'human_2'

        world = MultiAgentDialogWorld(opt=opt,
                                      agents=[
                                          human_agent_1, human_agent_2,
                                          mturk_agent_1, mturk_agent_2
                                      ])

        # Since we are using the regular MultiAgentDialogWorld, we do the following outside of the world instead.
        mturk_agent_ids = [mturk_agent_1.id, mturk_agent_2.id]
        all_agent_ids = [human_agent_1.id, human_agent_2.id] + mturk_agent_ids
        mturk_agent_1.mturk_agent_ids = mturk_agent_ids
        mturk_agent_1.all_agent_ids = all_agent_ids
        mturk_agent_2.mturk_agent_ids = mturk_agent_ids
        mturk_agent_2.all_agent_ids = all_agent_ids
        mturk_agent_1.create_hit()
        mturk_agent_2.create_hit()

        while not world.episode_done():
            world.parley()
        world.shutdown()
예제 #7
0
        def run_conversation(mturk_manager, opt, workers):
            # Create mturk agents
            mturk_agent_1 = workers[0]
            mturk_agent_2 = workers[1]

            # Create the local human agents
            human_agent_1 = LocalHumanAgent(opt=None)
            human_agent_1.id = human_agent_1_id

            world = MTurkMultiAgentDialogWorld(
                opt=opt, agents=[human_agent_1, mturk_agent_1, mturk_agent_2])

            while not world.episode_done():
                world.parley()

            world.shutdown()
예제 #8
0
        def run_conversation(mturk_manager, opt, workers):
            # Create mturk agents
            agents = workers
            if opt["use_local_human"]:
                # Create the local human agents
                human_agent_1 = LocalHumanAgent(opt={})
                human_agent_1.id = human_agent_1_id
                agents = [human_agent_1] + agents

            world = MTurkMultiAgentDialogWorld(opt=opt, agents=agents)

            while not world.episode_done():
                world.parley()

            world.save_data()
            world.shutdown()
예제 #9
0
        def run_conversation(mturk_manager, opt, workers):
            agents = workers[:]

            # Create a local agent
            if not opt['two_mturk_agents']:
                if 'model' in opt:
                    local_agent = create_agent(opt)
                else:
                    local_agent = LocalHumanAgent(opt=None)

                local_agent.id = local_agent_1_id
                agents.append(local_agent)

            opt["batchindex"] = mturk_manager.started_conversations

            world = MTurkDMGDialogWorld(
                opt=opt,
                agents=agents
            )

            log_timestamp = time.time()

            # Loop over all five rounds of the game
            for r in range(5):
                print("--- Starting round {} ---".format(r+1))
                while not world.episode_done():
                    world.parley()

                # Write the log data to file

                print("Writing log to file")
                if not os.path.exists("logs"):
                    os.makedirs("logs")
                with open('logs/dmg_pilot_data_{}_{}.json'.format(world.game_nr, log_timestamp), 'w') as f:
                    json.dump(world.conversation_log, f)

                if not r == 4:
                    # Reset the world for the next round
                    world.selections = defaultdict(lambda: dict())
                    world.round_log = world.reset_round_log()
                    world.turn_nr = -1
                    world.round_nr += 1
                    world.doneCounter = 0
                    world.episodeDone = False

                else:
                    world.shutdown()
예제 #10
0
파일: run.py 프로젝트: jojonki/ParlAI
        def run_conversation(mturk_manager, opt, workers):
            # Create mturk agents
            mturk_agent_1 = workers[0]
            mturk_agent_2 = workers[1]

            # Create the local human agents
            human_agent_1 = LocalHumanAgent(opt=None)
            human_agent_1.id = human_agent_1_id

            world = MTurkMultiAgentDialogWorld(
                opt=opt,
                agents=[human_agent_1, mturk_agent_1, mturk_agent_2]
            )

            while not world.episode_done():
                world.parley()

            world.shutdown()
예제 #11
0
        def run_conversation(mturk_manager, opt, workers):
            agents = workers[:]

            # Create a local agent
            if not opt['two_mturk_agents']:
                if 'model' in opt:
                    local_agent = create_agent(opt)
                else:
                    local_agent = LocalHumanAgent(opt=None)

                local_agent.id = local_agent_1_id
                agents.append(local_agent)

            opt["batchindex"] = mturk_manager.started_conversations

            world = MTurkDealNoDealDialogWorld(opt=opt, agents=agents)

            while not world.episode_done():
                world.parley()

            world.shutdown()
예제 #12
0
파일: run.py 프로젝트: ahiroto/ParlAI
        def run_conversation(mturk_manager, opt, workers):
            agents = workers[:]

            # Create a local agent
            if not opt['two_mturk_agents']:
                if 'model' in opt:
                    local_agent = create_agent(opt)
                else:
                    local_agent = LocalHumanAgent(opt=None)

                local_agent.id = local_agent_1_id
                agents.append(local_agent)

            opt["batchindex"] = mturk_manager.started_conversations

            world = MTurkDealNoDealDialogWorld(
                opt=opt,
                agents=agents
            )

            while not world.episode_done():
                world.parley()

            world.shutdown()
예제 #13
0
        def run_conversation(mturk_manager, opt, workers):
            """
            Runs the conversation
            :param mturk_manager: MTurk manager
            :param opt: command line arguments
            :param workers: list of workers
            :return: Nothing.
            """
            global game_id
            global worker_record

            conversation_start_time = time.time()

            # Copy workers into agents list
            agents = workers[:]
            # Get worker names
            names = get_worker_names(agents)
            print(names)

            # Create a local agent
            if not opt['two_mturk_agents']:
                if 'model' in opt:
                    local_agent = create_agent(opt)
                else:
                    local_agent = LocalHumanAgent(opt=None)

                local_agent.id = local_agent_1_id
                agents.append(local_agent)

            opt["batchindex"] = mturk_manager.started_conversations

            print("Loading game {}".format(game_id))

            print(list(worker_record.keys()))
            print(agents[0].worker_id)
            print(agents[1].worker_id)

            # If the workers never played before, start with the warm-up round
            if (agents[0].worker_id
                    not in worker_record) and (agents[1].worker_id
                                               not in worker_record):
                world = MTurkDMGDialogWarmupWorld(
                    opt=opt,
                    agents=agents,
                )

                print("--- Starting Warming-Up Round ---")
                while not world.episode_done():
                    if world.parley():
                        break

            world = MTurkDMGDialogWorld(opt=opt,
                                        agents=agents,
                                        game_id=game_id,
                                        names=names)

            get_pay = {agents[0].worker_id: False, agents[1].worker_id: False}

            print("--- Starting Game ---")
            while not world.episode_done():
                print("Parley!")
                world.parley()

            print("# # # DONE # # #")

            if world.disconnected:
                print("Game ended due to disconnect.")
                if world.round_nr > 1:
                    for agent in agents:
                        if not agent.disconnected:
                            print("CHECK: Agent {} did NOT disconnect".format(
                                agent.worker_id))
                            get_pay[agent.worker_id] = True
                        else:
                            print("CHECK: Agent {} DID disconnect".format(
                                agent.worker_id))

            else:
                # Only save records when game was complete
                print("Updating records")
                update_records(agents, game_id)
                save_records()

                if world.total_score > 24:
                    print("Total score was above 24, paying both workers.")
                    get_pay = {
                        agents[0].worker_id: True,
                        agents[1].worker_id: True
                    }
                else:
                    print("Score too low!")

            if world.end_time:
                conversation_end_time = world.end_time
            else:
                conversation_end_time = conversation_start_time
            world.shutdown()
            print("# # # Game ended # # #")

            duration = conversation_end_time - conversation_start_time
            duration_mins = duration / 60.0
            time_bonus = None

            if duration_mins > 1:
                if duration_mins >= 25:
                    time_bonus = 1.50
                else:
                    time_bonus = int(duration_mins - 10) * 0.10
                    time_bonus = round(time_bonus, 2)

            if time_bonus and time_bonus > 1.5:
                time_bonus = 1.5
            if time_bonus and time_bonus < 0:
                time_bonus = None
            pay_workers(agents, get_pay, time_bonus)
            print("Conversation closed.")