예제 #1
0
 def test_score_computer_win(self):
     gameState = [
         [-1,  0,  0,  0, 0, 0, 0],
         [-1,  0,  0,  0, 0, 0, 0],
         [ 1,  0,  0,  0, 0, 0, 0],
         [-1,  1,  0,  0, 0, 0, 0],
         [ 1,  1,  1,  0, 0, 0, 0],
         [-1, -1, -1,  1, 0, 0, 0]
     ]
     score = connect4.evaluateScore(gameState, self.player, self.opponent)
     self.assertEqual(score, float("inf"))
예제 #2
0
    def test_score_opponent_win(self):
        gameState = [
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [-1, 0, 0, 0, 0, 0, 0],
            [-1, 0, 0, 0, 0, 0, 1],
            [-1, 0, 0, 0, 0, 0, 1],
            [-1, 0, 0, 0, 0, 0, 1]
        ]
        score = connect4.evaluateScore(gameState, self.player, self.opponent)
        self.assertEqual(score, float("-inf"))

        gameState = [
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 1],
            [ 0, 0, 0, 0, 0, 0, 1],
            [-1,-1,-1,-1, 0, 0, 1]
        ]
        score = connect4.evaluateScore(gameState, self.player, self.opponent)
        self.assertEqual(score, float("-inf"))
예제 #3
0
    def test_score_potential_wins(self):
        gameState = [
            [ 1, 0,  0,  0, 0, 0, 0],
            [-1, 0,  0,  0, 0, 0, 0],
            [-1, 0,  1, -1, 0, 0, 0],
            [-1, 0, -1,  1, 0, 0, 0],
            [ 1, 0,  1,  1, 0, 0, 0],
            [-1, 0, -1, -1, 0, 0, 0]
        ]
        score = connect4.evaluateScore(gameState, self.player, self.opponent)
        self.assertEqual(score, 0)

        gameState = [
            [ 1, 0,  0,  0,  0, 0, 0],
            [-1, 0,  0,  0,  0, 0, 0],
            [ 1, 0,  1,  1,  1, 0, 0],
            [-1, 0, -1, -1,  1, 0, 1],
            [-1, 0, -1, -1,  1, 0, 1],
            [-1, 0, -1, -1, -1, 0, 1]
        ]
        score = connect4.evaluateScore(gameState, self.player, self.opponent)
        self.assertEqual(score, 0)