def test_is_invalid_move_because_of_ko4_not_ko_corner(self): #Current move is not surrounded by opponents' stones move = (0, 1) board_grid = [[-1, 0, 0, 0], [1, -1, 0, 0], [0, 0, 0, 0], [1, 0, 0, 0]] game_history = [(1, 3, 0), (-1, 0, 0), (1, 1, 0), (-1, 1, 1)] board = GoBoard(board_dimension=4, player=1, board_grid=board_grid, game_history=game_history) self.assertFalse(GoUtils._is_invalid_move_because_of_ko(board, move))
def test_is_invalid_move_because_of_ko3_ko_center(self): move = (2, 2) board_grid = [[0, 0, 0, 0], [0, 1, -1, 0], [1, -1, 0, -1], [0, 1, -1, 0]] game_history = [(1, 2, 0), (-1, 2, 3), (1, 1, 1), (-1, 1, 2), (1, 2, 2), (-1, 3, 2), (1, 3, 1), (-1, 2, 1)] board = GoBoard(board_dimension=4, player=1, board_grid=board_grid, game_history=game_history) self.assertTrue(GoUtils._is_invalid_move_because_of_ko(board, move))
def test_is_invalid_move_because_of_ko5_not_ko_center(self): #Current move captures two adjacent groups move = (1, 2) board_grid = [[0, 1, -1, 1], [1, -1, 0, -1], [0, 1, -1, 0], [0, 0, 0, 0]] game_history = [(1, 1, 0), (-1, 0, 2), (1, 0, 1), (-1, 2, 2), (1, 2, 1), (-1, 1, 3), (1, 0, 3), (-1, 1, 1)] board = GoBoard(board_dimension=4, player=1, board_grid=board_grid, game_history=game_history) self.assertFalse(GoUtils._is_invalid_move_because_of_ko(board, move))
def test_is_invalid_move_because_of_ko7_not_ko_center(self): #stone with no liberty from 2's position was not played in the last move move = (2, 2) board_grid = [[0, 0, 0, 0], [0, 1, -1, 0], [1, -1, 0, -1], [0, 1, -1, 0]] game_history = [(1, 1, 1), (-1, 1, 2), (1, 2, 2), (-1, 2, 3), (1, 3, 1), (-1, 3, 2), (1, 2, 0), (-1, 2, 1), (1, -1, -1), (-1, -1, -1)] board = GoBoard(board_dimension=4, player=1, board_grid=board_grid, game_history=game_history) self.assertFalse(GoUtils._is_invalid_move_because_of_ko(board, move))
def test_is_invalid_move_because_of_ko6_not_ko_center(self): #Capture Two stones that are connected from the move move = (2, 1) board_grid = [[0, 0, 0, 0, 0], [0, 1, -1, -1, 0], [1, 0, 1, 1, -1], [0, 1, -1, -1, 0], [0, 0, 0, 0, 0]] game_history = [(1, 1, 1), (-1, 1, 2), (1, 2, 2), (-1, 1, 3), (1, 2, 3), (-1, 2, 4), (1, -1, -1), (-1, 3, 3), (1, 3, 1), (-1, 3, 2), (1, 2, 0)] board = GoBoard(board_dimension=5, player=-1, board_grid=board_grid, game_history=game_history) self.assertFalse(GoUtils._is_invalid_move_because_of_ko(board, move))