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"))
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"))
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)