Beispiel #1
0
 def test_equality_false(self):
     table_a = LookupTable.from_pattern((C, D), 1, 0, 0)
     table_b = LookupTable.from_pattern((D, C), 1, 0, 0)
     table_c = LookupTable.from_pattern((C, D), 0, 1, 0)
     self.assertFalse(table_a.__eq__(table_b))
     self.assertFalse(table_a.__eq__(table_c))
     self.assertFalse(table_a.__eq__(table_a.dictionary))
Beispiel #2
0
 def test_equality_false(self):
     table_a = LookupTable.from_pattern((C, D), 1, 0, 0)
     table_b = LookupTable.from_pattern((D, C), 1, 0, 0)
     table_c = LookupTable.from_pattern((C, D), 0, 1, 0)
     self.assertFalse(table_a.__eq__(table_b))
     self.assertFalse(table_a.__eq__(table_c))
     self.assertFalse(table_a.__eq__(table_a.dictionary))
Beispiel #3
0
 def test_from_pattern_raises_error_pattern_len_ne_dict_size(self):
     too_big = (C, ) * 17
     too_small = (C, ) * 15
     just_right = (C, ) * 16
     with self.assertRaises(ValueError):
         LookupTable.from_pattern(too_big, 2, 2, 0)
     with self.assertRaises(ValueError):
         LookupTable.from_pattern(too_small, 2, 2, 0)
     self.assertIsInstance(LookupTable.from_pattern(just_right, 2, 2, 0),
                           LookupTable)
Beispiel #4
0
 def test_from_pattern_raises_error_pattern_len_ne_dict_size(self):
     too_big = (C,) * 17
     too_small = (C,) * 15
     just_right = (C,) * 16
     with self.assertRaises(ValueError):
         LookupTable.from_pattern(too_big, 2, 2, 0)
     with self.assertRaises(ValueError):
         LookupTable.from_pattern(too_small, 2, 2, 0)
     self.assertIsInstance(
         LookupTable.from_pattern(just_right, 2, 2, 0), LookupTable
     )
Beispiel #5
0
 def test_from_pattern(self):
     pattern = (C, D, D, C, C, D, D, C)
     table = LookupTable.from_pattern(pattern,
                                      player_depth=2,
                                      op_depth=1,
                                      op_openings_depth=0)
     self.assertEqual(table.dictionary,
                      make_keys_into_plays(self.lookup_dict))
Beispiel #6
0
 def test_display_default(self):
     table = LookupTable.from_pattern((C, ) * 8,
                                      player_depth=2,
                                      op_depth=0,
                                      op_openings_depth=1)
     self.assertEqual(table.display(),
                      ("op_openings|self_plays | op_plays  \n" +
                       "     C     ,   C, C    ,           : C,\n" +
                       "     C     ,   C, D    ,           : C,\n" +
                       "     C     ,   D, C    ,           : C,\n" +
                       "     C     ,   D, D    ,           : C,\n" +
                       "     D     ,   C, C    ,           : C,\n" +
                       "     D     ,   C, D    ,           : C,\n" +
                       "     D     ,   D, C    ,           : C,\n" +
                       "     D     ,   D, D    ,           : C,\n"))
Beispiel #7
0
 def test_display_assign_order(self):
     table = LookupTable.from_pattern((C, ) * 8,
                                      player_depth=0,
                                      op_depth=3,
                                      op_openings_depth=0)
     self.assertEqual(
         table.display(sort_by=('op_openings', 'op_plays', 'self_plays')),
         ("op_openings| op_plays  |self_plays \n" +
          "           ,  C, C, C  ,           : C,\n" +
          "           ,  C, C, D  ,           : C,\n" +
          "           ,  C, D, C  ,           : C,\n" +
          "           ,  C, D, D  ,           : C,\n" +
          "           ,  D, C, C  ,           : C,\n" +
          "           ,  D, C, D  ,           : C,\n" +
          "           ,  D, D, C  ,           : C,\n" +
          "           ,  D, D, D  ,           : C,\n"))
Beispiel #8
0
 def test_display_default(self):
     table = LookupTable.from_pattern(
         (C,) * 8, player_depth=2, op_depth=0, op_openings_depth=1
     )
     self.assertEqual(
         table.display(),
         (
             "op_openings|self_plays | op_plays  \n"
             + "     C     ,   C, C    ,           : C,\n"
             + "     C     ,   C, D    ,           : C,\n"
             + "     C     ,   D, C    ,           : C,\n"
             + "     C     ,   D, D    ,           : C,\n"
             + "     D     ,   C, C    ,           : C,\n"
             + "     D     ,   C, D    ,           : C,\n"
             + "     D     ,   D, C    ,           : C,\n"
             + "     D     ,   D, D    ,           : C,\n"
         ),
     )
Beispiel #9
0
 def test_display_assign_order(self):
     table = LookupTable.from_pattern(
         (C,) * 8, player_depth=0, op_depth=3, op_openings_depth=0
     )
     self.assertEqual(
         table.display(sort_by=("op_openings", "op_plays", "self_plays")),
         (
             "op_openings| op_plays  |self_plays \n"
             + "           ,  C, C, C  ,           : C,\n"
             + "           ,  C, C, D  ,           : C,\n"
             + "           ,  C, D, C  ,           : C,\n"
             + "           ,  C, D, D  ,           : C,\n"
             + "           ,  D, C, C  ,           : C,\n"
             + "           ,  D, C, D  ,           : C,\n"
             + "           ,  D, D, C  ,           : C,\n"
             + "           ,  D, D, D  ,           : C,\n"
         ),
     )
Beispiel #10
0
 def test_not_equal(self):
     table_a = LookupTable(self.lookup_dict)
     table_b = LookupTable(self.lookup_dict)
     not_equal = LookupTable.from_pattern((C, C), 1, 0, 0)
     self.assertFalse(table_a.__ne__(table_b))
     self.assertTrue(table_a.__ne__(not_equal))
Beispiel #11
0
 def test_from_pattern(self):
     pattern = (C, D, D, C, C, D, D, C)
     table = LookupTable.from_pattern(
         pattern, player_depth=2, op_depth=1, op_openings_depth=0
     )
     self.assertEqual(table.dictionary, make_keys_into_plays(self.lookup_dict))
Beispiel #12
0
 def test_not_equal(self):
     table_a = LookupTable(self.lookup_dict)
     table_b = LookupTable(self.lookup_dict)
     not_equal = LookupTable.from_pattern((C, C), 1, 0, 0)
     self.assertFalse(table_a.__ne__(table_b))
     self.assertTrue(table_a.__ne__(not_equal))