class TestConnectionAnalysis(unittest.TestCase): def setUp(self): self.tictactoe = TicTacToe(4) action_sequenz = [(0, 0), (3, 2), (0, 3), (1, 0), (1, 3), (2, 0), (3, 0), (0, 2), (3, 1), (2, 2), (2, 1), (1, 1), (0, 1), (1, 2)] self.tictactoe.initialize_game_matrix_with_action_sequence( action_sequenz) def test_get_valid_positions_by_two_positions_1(self): self.assertEqual([(0, 0), (1, 1), (2, 2), (3, 3)], self.tictactoe. get_victory_relevant_positions_by_two_given_positions( (0, 0), (1, 1))) def test_get_valid_positions_by_two_positions_2(self): self.assertEqual([(3, 0), (2, 1), (1, 2), (0, 3)], self.tictactoe. get_victory_relevant_positions_by_two_given_positions( (3, 0), (1, 2))) def test_get_valid_positions_by_two_positions_3(self): self.assertEqual([(1, 0), (1, 1), (1, 2), (1, 3)], self.tictactoe. get_victory_relevant_positions_by_two_given_positions( (1, 0), (1, 2))) def test_get_valid_positions_by_two_positions_4(self): self.assertEqual([(0, 1), (1, 1), (2, 1), (3, 1)], self.tictactoe. get_victory_relevant_positions_by_two_given_positions( (2, 1), (0, 1))) def test_is_connection_pure_1(self): self.assertTrue(self.tictactoe.is_connection_pure((0, 3), (1, 3), 'X')) def test_is_connection_pure_2(self): self.assertTrue(self.tictactoe.is_connection_pure((0, 3), (3, 3), 'X')) def test_is_connection_pure_3(self): self.assertFalse(self.tictactoe.is_connection_pure((1, 1), (1, 2), 'O')) def test_is_connection_pure_4(self): self.assertFalse(self.tictactoe.is_connection_pure((1, 1), (1, 2), 'X')) def test_is_connection_pure_5(self): self.assertTrue(self.tictactoe.is_connection_pure((1, 2), (3, 2), 'O')) def test_is_connection_pure_6(self): self.assertFalse(self.tictactoe.is_connection_pure((1, 1), (2, 2), 'O')) def test_is_connection_pure_7(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertTrue(tictactoe.is_connection_pure((1, 1), (2, 2), 'X')) def test_is_connection_pure_8(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertTrue(tictactoe.is_connection_pure((3, 0), (1, 2), 'O')) def test_count_tokens_in_pure_connection_1(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertEqual( 3, tictactoe.count_tokens_in_pure_connection((0, 0), (1, 1), 'X')) def test_count_tokens_in_pure_connection_2(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertEqual( 4, tictactoe.count_tokens_in_pure_connection((3, 0), (1, 2), 'O')) def test_count_tokens_in_pure_connection_3(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertEqual( 0, tictactoe.count_tokens_in_pure_connection((0, 0), (3, 0), 'O')) def test_count_tokens_in_pure_connection_4(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertEqual( 0, tictactoe.count_tokens_in_pure_connection((2, 2), (3, 2), 'X'))
def test_is_connection_pure_8(self): tictactoe = TicTacToe(4) action_sequence = [(0, 0), (3, 0), (1, 1), (2, 1), (2, 2), (1, 2), (3, 2), (0, 3)] tictactoe.initialize_game_matrix_with_action_sequence(action_sequence) self.assertTrue(tictactoe.is_connection_pure((3, 0), (1, 2), 'O'))