def test_set_get_preferences(self): action = Action() action.name = "test_action" p = Preferences() p.set_goodness(action, 1) agent = Agent(0, 0, 0, 0, 0) agent.set_preferences(p) p_returned = agent.get_preferences() self.assertEqual(p_returned.get_goodness(action), 1)
def test_emotions_for_observed_action(self): agent_1 = Agent(0, 0, 0, 0, 0) agent_2 = Agent(-1, -1, 1, -1, 1) action = Action() action.name = "Hit" p = Preferences() p.set_goodness(action, -.5) p.set_praiseworthiness(action, -1) p.set_love(agent_2.entity_id, -.5) agent_1.set_preferences(p) agent_2.set_preferences(p) emotions = agent_1._emotions_for_observed_action( action, agent_1.entity_id, agent_2.entity_id ) self.assertEqual(len(emotions), 2) emotion_1 = emotions.pop() self.assertIsInstance(emotion_1, Gloating) self.assertEqual(emotion_1.amount, .25) emotion_2 = emotions.pop() self.assertIsInstance(emotion_2, Remorse) self.assertEqual(emotion_2.amount, 1)