Exemplo n.º 1
0
    def test_analyse_cooperation_ratio(self):
        tf = TransitiveFingerprint(axl.TitForTat)
        filename = "test_outputs/test_fingerprint.csv"
        with open(filename, "w") as f:
            f.write(
                """Interaction index,Player index,Opponent index,Repetition,Player name,Opponent name,Actions
0,0,1,0,Player0,Player1,CCC
0,1,0,0,Player1,Player0,DDD
1,0,1,1,Player0,Player1,CCC
1,1,0,1,Player1,Player0,DDD
2,0,2,0,Player0,Player2,CCD
2,2,0,0,Player2,Player0,DDD
3,0,2,1,Player0,Player2,CCC
3,2,0,1,Player2,Player0,DDD
4,0,3,0,Player0,Player3,CCD
4,3,0,0,Player3,Player0,DDD
5,0,3,1,Player0,Player3,DCC
5,3,0,1,Player3,Player0,DDD
6,0,4,2,Player0,Player4,DDD
6,4,0,2,Player4,Player0,DDD
7,0,4,3,Player0,Player4,DDD
7,4,0,3,Player4,Player0,DDD"""
            )
        data = tf.analyse_cooperation_ratio(filename)
        expected_data = np.array(
            [[1, 1, 1], [1, 1, 1 / 2], [1 / 2, 1, 1 / 2], [0, 0, 0]]
        )
        self.assertTrue(np.array_equal(data, expected_data))
Exemplo n.º 2
0
    def test_analyse_cooperation_ratio(self):
        tf = TransitiveFingerprint(axl.TitForTat)
        path = pathlib.Path("test_outputs/test_fingerprint.csv")
        filename = axl_filename(path)
        with open(filename, "w") as f:
            f.write(
                """Interaction index,Player index,Opponent index,Repetition,Player name,Opponent name,Actions
0,0,1,0,Player0,Player1,CCC
0,1,0,0,Player1,Player0,DDD
1,0,1,1,Player0,Player1,CCC
1,1,0,1,Player1,Player0,DDD
2,0,2,0,Player0,Player2,CCD
2,2,0,0,Player2,Player0,DDD
3,0,2,1,Player0,Player2,CCC
3,2,0,1,Player2,Player0,DDD
4,0,3,0,Player0,Player3,CCD
4,3,0,0,Player3,Player0,DDD
5,0,3,1,Player0,Player3,DCC
5,3,0,1,Player3,Player0,DDD
6,0,4,2,Player0,Player4,DDD
6,4,0,2,Player4,Player0,DDD
7,0,4,3,Player0,Player4,DDD
7,4,0,3,Player4,Player0,DDD""")
        data = tf.analyse_cooperation_ratio(filename)
        expected_data = np.array([[1, 1, 1], [1, 1, 1 / 2], [1 / 2, 1, 1 / 2],
                                  [0, 0, 0]])
        self.assertTrue(np.array_equal(data, expected_data))
Exemplo n.º 3
0
    def test_analyse_cooperation_ratio(self):
        tf = TransitiveFingerprint(axl.TitForTat)
        filename = "test_outputs/test_fingerprint.csv"
        with open(filename, "w") as f:
            f.write("""0,1,Player0,Player1,CCC,DDD
0,1,Player0,Player1,CCC,DDD
0,2,Player0,Player2,CCD,DDD
0,2,Player0,Player2,CCC,DDD
0,3,Player0,Player3,CCD,DDD
0,3,Player0,Player3,DCC,DDD
0,4,Player0,Player3,DDD,DDD
0,4,Player0,Player3,DDD,DDD""")
        data = tf.analyse_cooperation_ratio(filename)
        expected_data = np.array([[1, 1, 1], [1, 1, 1 / 2], [1 / 2, 1, 1 / 2],
                                  [0, 0, 0]])
        self.assertTrue(np.array_equal(data, expected_data))