示例#1
0
 def _check(self, tup_tree, tree_name, expected):
     tree = make_tree(tup_tree)
     v = alpha_beta_search(tree, 10, tree_eval, tree_get_next_move, is_leaf)
     try:
         self.assertEqual(v, expected)
     except Exception as e:
         self.log.error("%s:\n%s", tree_name, tree_as_string(tree))
         self.log.error("BEST MOVE: %s", format(v))
         self.log.error("EXPECTED: %s", format(expected))
         raise e
示例#2
0
          )


#
# Test alpha beta search using the tree_search framework,
# see tree_search.py
#
TEST_TREE_1 = tree_searcher.make_tree(("A", None,
                                       ("B", None,
                                        ("C", None,
                                         ("D", 2),
                                         ("E", 2)),
                                        ("F", None,
                                         ("G", 0),
                                         ("H", 4))
                                        ),
                                       ("I", None,
                                        ("J", None,
                                         ("K", 6),
                                         ("L", 8)),
                                        ("M", None,
                                         ("N", 4),
                                         ("O", 6))
                                        )
                                       ))

TREE_1_EXPECTED_BEST_MOVE = "I"

def run_test_tree_search_1_getargs():
    return [ 'alpha_beta_search', 'TEST_TREE_1', 10 ]

def run_test_tree_search_1_testanswer(val, original_val = None):
示例#3
0
                                            ( 0,0,1,0,0,0,0 ),
                                            ),
                                          current_player = 1)

# Generic board
BASIC_BOARD = ConnectFourBoard()

TEST_TREE_1 = tree_searcher.make_tree(("A", None,
                                       ("B", None,
                                        ("C", None,
                                         ("D", 2),
                                         ("E", 2)),
                                        ("F", None,
                                         ("G", 0),
                                         ("H", 4))
                                        ),
                                       ("I", None,
                                        ("J", None,
                                         ("K", 6),
                                         ("L", 8)),
                                        ("M", None,
                                         ("N", 4),
                                         ("O", 6))
                                        )
                                       ))

TEST_TREE_2 = tree_searcher.make_tree(("A", None,
                                       ("B", None,
                                        ("C", None,
                                         ("D", 6),
                                         ("E", 4)),
                                        ("F", None,