def test_long_diagonal(self): board = [ [1, 0, 0, 0, 0, 0, 0, 1], [0, 2, 0, 0, 0, 0, 2, 0], [0, 0, 2, 0, 0, 2, 0, 0], [0, 0, 0, 2, 2, 0, 0, 0], [0, 0, 0, 2, 2, 0, 0, 0], [0, 0, 2, 0, 0, 2, 0, 0], [0, 2, 0, 0, 0, 0, 2, 0], [1, 0, 0, 0, 0, 0, 0, 1], ] returned_val = client.diagonal_converted_tokens(1, board, [0, 0]) expected_val = 6 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [0, 7]) expected_val = 6 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [7, 0]) expected_val = 6 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [7, 7]) expected_val = 6 self.assertEqual(returned_val, expected_val)
def test_diagonal_starting_on_edge(self): board = [ [0, 0, 1, 0, 0, 0, 0, 0], [0, 2, 0, 0, 0, 0, 0, 0], [1, 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, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [0, 2]) expected_val = 1 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [2, 0]) expected_val = 1 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [5, 7]) expected_val = 1 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [7, 5]) expected_val = 1 self.assertEqual(returned_val, expected_val)
def test_diagonal_ending_on_edge_player(self): board = [ [1, 0, 0, 0, 1, 0, 0, 0], [0, 2, 0, 2, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 2, 0], [0, 0, 0, 0, 0, 0, 0, 1], ] returned_val = client.diagonal_converted_tokens(1, board, [2, 2]) expected_val = 2 self.assertEqual(returned_val, expected_val) returned_val = client.diagonal_converted_tokens(1, board, [5, 5]) expected_val = 2 self.assertEqual(returned_val, expected_val)
def test_diagonal_none_last_col(self): board = [ [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, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 2], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [6, 6]) expected_val = 0 self.assertEqual(returned_val, expected_val)
def test_diagonal_none_col_zero(self): board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [2, 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, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [1, 1]) expected_val = 0 self.assertEqual(returned_val, expected_val)
def test_diagonal_all_directions(self): """ Test if can find sum of diagonals in all directions. """ board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 2, 0, 2, 0, 0], [0, 0, 0, 2, 1, 0, 0, 0], [0, 0, 0, 2, 0, 2, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [3, 4]) expected_val = 4 self.assertEqual(returned_val, expected_val)
def test_diagonal_down_right(self): """ Test if can find 1 spot down right. """ board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 1, 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], [0, 0, 0, 0, 0, 0, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [1, 2]) expected_val = 1 self.assertEqual(returned_val, expected_val)
def test_diagonal_no_options(self): """ Test if can find all possible adjacent spaces """ board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 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, 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], ] returned_val = client.diagonal_converted_tokens(1, board, [1, 1]) expected_val = 0 self.assertEqual(returned_val, expected_val)
def test_diagonal_up_left(self): """ Test if can find 1 spot up left. """ board = [ [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 2, 1, 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], [0, 0, 0, 0, 0, 0, 0, 0], ] returned_val = client.diagonal_converted_tokens(1, board, [3, 4]) expected_val = 1 self.assertEqual(returned_val, expected_val)
def test_no_options_left(self): """ This test broke the program when testing against the ai. """ board = [[2, 2, 2, 2, 2, 1, 1, 1], [2, 1, 2, 2, 2, 1, 1, 2], [2, 2, 1, 2, 1, 1, 1, 1], [2, 2, 2, 1, 1, 2, 1, 1], [2, 1, 2, 2, 1, 2, 1, 2], [2, 1, 1, 1, 2, 1, 1, 2], [2, 1, 1, 1, 1, 2, 1, 2], [2, 1, 2, 0, 1, 2, 2, 0]] diag_count = client.diagonal_converted_tokens(1, board, [7, 3]) self.assertEqual(diag_count, 0) # import pdb; pdb.set_trace() col_count = client.column_converted_tokens(1, board, [7, 3]) self.assertEqual(col_count, 1) row_count = client.row_converted_tokens(1, board, [7, 3]) self.assertEqual(row_count, 0) best_move, valid_moves = client.get_valid_moves_and_best(1, board) expected_val = [[7, 3], [7, 7]] client.print_board(board) print("Valid Moves Returned: ") print(valid_moves) print("\nExpected Valid Moves: ") print(expected_val) self.assertEqual(len(expected_val), len(valid_moves))