示例#1
0
    def estimation(self, time_step, main_sim, enemy_action_prob, types):
        # For the unkown agents, estimating the parameters and types

        loaded_items_list = self.find_loaded_item(main_sim)
        for unknown_agent in self.visible_agents:
            if unknown_agent is not None:
                # 1. Selecting the types
                parameter_estimation = unknown_agent.agents_parameter_estimation
                if parameter_estimation.type_selection_mode == 'AS':
                    selected_types = types
                if parameter_estimation.type_selection_mode == 'BS':
                    selected_types = parameter_estimation.UCB_selection(
                        time_step)  # returns l1, l2, f1, f2,w

                # 2. Defining the next agent action or appending the action
                # for the history based method
                if parameter_estimation.train_mode == 'history_based':
                    parameter_estimation.action_history.append(
                        unknown_agent.next_action)
                    if unknown_agent.next_action != 'L':
                        parameter_estimation.actions_to_reach_target.append(
                            unknown_agent.next_action)

                # 3. Estimating
                if unknown_agent.next_action is not None:
                    tmp_sim = copy(main_sim)
                    tmp_previous_state = copy(self.previous_state)
                    parameter_estimation.process_parameter_estimations(
                        unknown_agent, tmp_previous_state, tmp_sim,
                        enemy_action_prob, selected_types, loaded_items_list)
示例#2
0
    def estimation(self, time_step, main_sim, enemy_action_prob, types,
                   actions, current_state):
        # For the unknown agents, estimating the parameters and types
        loaded_items_list = self.find_loaded_item(main_sim)
        for unknown_agent in self.agent_memory:
            if unknown_agent is not None:
                # 1. Selecting the types
                parameter_estimation = unknown_agent.agents_parameter_estimation
                if parameter_estimation.type_selection_mode == 'AS':
                    selected_types = types
                if parameter_estimation.type_selection_mode == 'BS':
                    selected_types = parameter_estimation.UCB_selection(
                        time_step)  # returns l1, l2, f1, f2,w

                # 2. Defining the next agent action or appending the action
                # for the history based method
                if parameter_estimation.train_mode == 'history_based':
                    parameter_estimation.action_history.append(
                        unknown_agent.next_action)
                    if unknown_agent.next_action != 'L':
                        parameter_estimation.actions_to_reach_target.append(
                            unknown_agent.next_action)

                # 3. Estimating
                # print unknown_agent.next_action

                if self.agent_is_visible(
                        unknown_agent
                ) and unknown_agent.next_action is not None:

                    tmp_sim = copy(main_sim)

                    tmp_previous_state = copy(self.previous_state)

                    parameter_estimation.process_parameter_estimations(
                        unknown_agent, tmp_previous_state, tmp_sim,
                        enemy_action_prob, selected_types, loaded_items_list,
                        True)

                elif current_state is not None:

                    for agent in current_state.agents:
                        if agent.index == unknown_agent.index:
                            next_action = agent.next_action
                            break

                    previous_state = self.generate_previous_state(
                        unknown_agent, next_action, current_state)

                    unknown_agent.next_action = next_action

                    #parameter_estimation.unseen_parameter_estimation_not_update(unknown_agent,selected_types)
                    parameter_estimation.process_parameter_estimations(
                        unknown_agent, previous_state, current_state,
                        enemy_action_prob, selected_types, loaded_items_list,
                        True)

        print "End of Estimationnnnnnnnn----------------------------------"