コード例 #1
0
 def test_get_praiseworthiness(self):
     p = Preferences()
     a = Action()
     a.name = "punch"
     p.set_goodness(a, 1)
     g = p.get_goodness(a)
     self.assertEqual(g, 1)
コード例 #2
0
    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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: agent.py プロジェクト: GeorgeNagel/emotion-ai
 def get_preferences(self):
     if self._preferences is None:
         self._preferences = Preferences()
     return self._preferences
コード例 #5
0
 def test_get_love(self):
     p = Preferences()
     o = Object()
     p.set_love(o.entity_id, 1)
     l = p.get_love(o.entity_id)
     self.assertEqual(l, 1)
コード例 #6
0
 def test_upper_limit(self):
     p = Preferences()
     o = Object()
     with self.assertRaises(ValueError):
         p.set_love(o.entity_id, 20)
コード例 #7
0
 def test_upper_limit(self):
     p = Preferences()
     a = Action()
     a.name = "punch"
     with self.assertRaises(ValueError):
         p.set_goodness(a, 20)
コード例 #8
0
 def test_lower_limit(self):
     p = Preferences()
     a = Action()
     a.name = "punch"
     with self.assertRaises(ValueError):
         p.set_praiseworthiness(a, -20)
コード例 #9
0
ファイル: preferences.py プロジェクト: GeorgeNagel/emotion-ai
from ai.core.preferences import Preferences
from ai.example.action import Kill, RemoveDisguise


culture = Preferences()
culture.set_praiseworthiness(Kill, -1)
culture.set_goodness(Kill, -1)
culture.set_praiseworthiness(RemoveDisguise, 0)
culture.set_goodness(RemoveDisguise, 0)
コード例 #10
0
from ai.core.preferences import Preferences
from ai.example.action import Kill, RemoveDisguise

culture = Preferences()
culture.set_praiseworthiness(Kill, -1)
culture.set_goodness(Kill, -1)
culture.set_praiseworthiness(RemoveDisguise, 0)
culture.set_goodness(RemoveDisguise, 0)