def test_make_valid_move1(self): game = Game(self.player1, self.player2) gb = game.game_board game.who_plays_first() gb.update_board(game.who_is_moving(), 1) self.assertFalse(gb.is_space_free(1)) self.assertTrue(gb.is_space_free(3))
def test_who_plays_first(self): c1 = 0 c2 = 0 game = Game(self.player1, self.player2) n_samples = 1000 for i in range(n_samples): first = game.who_plays_first() if first == self.player1: c1 += 1 elif first == self.player2: c2 += 1 p = c1 / n_samples self.assertTrue(0.4 < p and p < 0.6)
def test_make_valid_move2(self): game = Game(self.player1, self.player2) gb = game.game_board game.who_plays_first() gb.update_board(game.who_is_moving(), 1) game.toggle_player() gb.update_board(game.who_is_moving(), 2) game.toggle_player() gb.update_board(game.who_is_moving(), 3) game.toggle_player() gb.update_board(game.who_is_moving(), 4) game.toggle_player() gb.update_board(game.who_is_moving(), 5) game.toggle_player() gb.update_board(game.who_is_moving(), 6) game.toggle_player() gb.update_board(game.who_is_moving(), 7) game.toggle_player() gb.update_board(game.who_is_moving(), 8) game.toggle_player() self.assertFalse(gb.is_board_full()) gb.update_board(game.who_is_moving(), 9) game.toggle_player() self.assertTrue(gb.is_board_full())