def test_EscolheParaGanharComLinha(self): board = Board() player_id = "x" computer_player = ComputerPlayer(computer_id=player_id, human_id="o") # Set pattern: # * | x | x Expect (0, 0) # ---+---+--- # | | # ---+---+--- # | | board.PlayPosition(0, 1, player_id) board.PlayPosition(0, 2, player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(0, 0, player_id)) self.assertTrue(board.PlayerWon(player_id))
def test_NaoDeixaOutroJogadorVencerComLinha(self): board = Board() player_id = "x" other_player_id = "o" computer_player = ComputerPlayer(computer_id=player_id, human_id=other_player_id) # Set pattern: # * | o | o Expect (0, 0) to be "x" # ---+---+--- # | | # ---+---+--- # | | board.PlayPosition(0, 1, other_player_id) board.PlayPosition(0, 2, other_player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(0, 0, player_id))
def test_VaiJogarParaVencerEmVezDeBloquar(self): board = Board() player_id = "x" other_player_id = "o" computer_player = ComputerPlayer(computer_id=player_id, human_id=other_player_id) # Set pattern: # | o | o Expect (2, 2) to be "x" # ---+---+--- # | | # ---+---+--- # x | x | * board.PlayPosition(0, 1, other_player_id) board.PlayPosition(0, 2, other_player_id) board.PlayPosition(2, 0, player_id) board.PlayPosition(2, 1, player_id) computer_player.Play(board) self.assertTrue(board.HasPosition(2, 2, player_id)) self.assertTrue(board.PlayerWon(player_id))