Esempio n. 1
0
    def test_utility_with_min_winning(self):
        expected_utility = -1

        winning_board = {
            (0, 0): 0,
            (0, 1): 0,
            (0, 2): 12,
            (0, 3): 0,
            (1, 0): 0,
            (1, 1): 0,
            (1, 2): 13,
            (1, 3): 0,
            (2, 0): 0,
            (2, 1): 0,
            (2, 2): 5,
            (2, 3): 0,
            (3, 0): 0,
            (3, 1): 0,
            (3, 2): 4,
            (3, 3): 0
        }
        game = NumericalTicTacToe()
        utility = game.utility(GameState(winning_board, Max), Min)

        self.assertEqual(expected_utility, utility)
Esempio n. 2
0
    def test_utility_with_full_board(self):
        expected_utility = 0
        full_board = {
            (0, 0): 10,
            (0, 1): 16,
            (0, 2): 12,
            (0, 3): 6,
            (1, 0): 3,
            (1, 1): 13,
            (1, 2): 11,
            (1, 3): 14,
            (2, 0): 1,
            (2, 1): 9,
            (2, 2): 15,
            (2, 3): 2,
            (3, 0): 5,
            (3, 1): 4,
            (3, 2): 7,
            (3, 3): 8
        }

        game = NumericalTicTacToe()
        utility = game.utility(GameState(full_board, Min), Max)

        self.assertEqual(expected_utility, utility)