def test_mini_max_search_success3(self): # Tests base case of minimax search with a positive depth on a game state wherein # no more moves are possible self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree4, Color.RED, 1)[0], 3) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree4, Color.BROWN, 2)[0], 0) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree4, Color.WHITE, 2)[0], 0) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree4, Color.BLACK, 2)[0], 3)
def test_mini_max_search_success7(self): # Tests minimax search with a depth of 4 on a game at least 2 levels deep (heterogeneous board) # Shows that applying a strategy on such a board always takes more than 1 second time1 = time.time() self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree7, Color.RED, 2), (4, ((0, 0), (2, 0)))) self.assertTrue(time.time() - time1 > 1)
def test_mini_max_search_success6(self): # Tests minimax search with a depth of 4 on a game at least 2 levels deep (heterogeneous board) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree5, Color.RED, 2), (5, ((1, 0), (3, 0))))
def test_mini_max_search_success5(self): # Tests minimax search with a depth of 4 on a game at least 4 levels deep (homogeneous board) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree2, Color.RED, 4), (8, ((1, 1), (2, 2))))
def test_mini_max_search_success2(self): # Tests base case of minimax search with a positive depth where only one move is # possible by Player 4 (id = 8) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree3, Color.BROWN, 1)[0], 0) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree3, Color.WHITE, 1)[0], 0)
def test_mini_max_search_success1(self): # Tests base case of minimax search with a depth of 0 self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree3, Color.RED, 0)[0], 3) self.assertEqual(Strategy._Strategy__mini_max_search(self.__tree3, Color.BROWN, 0)[0], 0)
def test_mini_max_search_fail5(self): # Tests failing mini_max_search due to invalid beta with self.assertRaises(TypeError): Strategy._Strategy__mini_max_search(self.__tree2, 1, 2, -VERY_LARGE_NUMBER, 'beta')
def test_mini_max_search_fail4(self): # Tests failing mini_max_search due to invalid alpha with self.assertRaises(TypeError): Strategy._Strategy__mini_max_search(self.__tree2, 1, 2, 'alpha', VERY_LARGE_NUMBER)
def test_mini_max_search_fail2(self): # Tests failing mini_max_search due to invalid maximizer id with self.assertRaises(TypeError): Strategy._Strategy__mini_max_search(self.__tree2, -1, 2, -VERY_LARGE_NUMBER, VERY_LARGE_NUMBER)
def test_mini_max_search_fail1(self): # Tests failing mini_max_search due to invalid node with self.assertRaises(TypeError): Strategy._Strategy__mini_max_search('not a node', 1, 2, -VERY_LARGE_NUMBER, VERY_LARGE_NUMBER)