def __init__(self, agent_id, ally_ids, enemy_ids): """Extend the constructor from the PacmanAgent superclass. Args: agent_id: The identifier of an agent. ally_ids: The identifier of all allies agents. enemy_ids: The identifier of all enemies agents. """ super(EaterPacmanAgent, self).__init__(agent_id, ally_ids, enemy_ids) self.eat_behavior = behaviors.EatBehavior()
def __init__(self, agent_id, ally_ids, enemy_ids): """Constructor for the BehaviorLearningPacmanAgent. Extend the PacmanAgent constructor. Setup the features the pacman will use, the behaviors, the explotation and exploration rate, initialize a QLearningWithApproximation object initialize behavior count and set test mode to 'False'. Args: agent_id: The identifier of the agent. ally_ids: The identifiers of all the allies. enemy_ids: The identifiers of all the enemies. """ super(BehaviorLearningPacmanAgent, self).__init__(agent_id, ally_ids, enemy_ids) self.features = [features.FoodDistanceFeature()] for enemy_id in enemy_ids: self.features.append(features.EnemyDistanceFeature(enemy_id)) for id_ in [agent_id] + ally_ids + enemy_ids: self.features.append(features.FragileAgentFeature(id_)) self.behaviors = [ behaviors.EatBehavior(), behaviors.FleeBehavior(), behaviors.SeekBehavior(), behaviors.PursueBehavior() ] self.K = 1.0 # Learning rate self.exploration_rate = 0.1 QLearning = learning.QLearningWithApproximation self.learning = QLearning(learning_rate=0.1, discount_factor=0.9, actions=self.behaviors, features=self.features, exploration_rate=self.exploration_rate) self.previous_behavior = self.behaviors[0] self.behavior_count = {} self.reset_behavior_count() self.test_mode = False
def __init__(self, agent_id, ally_ids, enemy_ids): super(BehaviorLearningPacmanAgent, self).__init__(agent_id, ally_ids, enemy_ids) self.features = [features.FoodDistanceFeature()] for enemy_id in enemy_ids: self.features.append(features.EnemyDistanceFeature(enemy_id)) for id_ in [agent_id] + ally_ids + enemy_ids: self.features.append(features.FragileAgentFeature(id_)) self.behaviors = [behaviors.EatBehavior(), behaviors.FleeBehavior(), behaviors.SeekBehavior(), behaviors.PursueBehavior()] self.K = 1.0 # Learning rate self.exploration_rate = 0.1 self.learning = learning.QLearningWithApproximation(learning_rate=0.1, discount_factor=0.9, actions=self.behaviors, features=self.features, exploration_rate=self.exploration_rate) self.previous_behavior = self.behaviors[0] self.behavior_count = {} self.reset_behavior_count() self.test_mode = False
def __init__(self, agent_id, ally_ids, enemy_ids): super(EaterPacmanAgent, self).__init__(agent_id, ally_ids, enemy_ids) self.eat_behavior = behaviors.EatBehavior()