Exemple #1
0
 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))
Exemple #2
0
 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))
Exemple #3
0
 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))
Exemple #4
0
 def test_PlayerId(self):
     computer_player = ComputerPlayer(computer_id="x", human_id="o")
     self.assertEqual(computer_player.Id(), "x")
Exemple #5
0
 def test_NaoDeixaOutroJogadorVencerComOutroTraversal(self):
     board = Board()
     player_id = "x"
     other_player_id = "o"
     computer_player = ComputerPlayer(computer_id=player_id,
                                      human_id=other_player_id)
Exemple #6
0
 def test_EscolheParaGanharComLinha(self):
     board = Board()
     player_id = "x"
     computer_player = ComputerPlayer(computer_id=player_id, human_id="o")