Determine which Go actions are legal. The board uses 0 for empty, 1 for Black, and -1 for White. On a board with side length n, intersection actions are numbered in row-major order from 0 to n squared minus one; action n squared means pass.
A group contains same-colour stones connected horizontally or vertically. Its liberties are adjacent empty intersections. A placement must be on an empty point. Adjacent opposing groups with no liberties are captured; the played stone's group must have a liberty after those captures. The resulting board must not match any supplied seen position, which is the positional-superko rule.
Pass is legal in every nonterminal state. A state is terminal after at least two consecutive passes or at least twice the board area in played actions.
Return a NumPy Boolean array of length n squared plus one, with one flag per intersection followed by pass. Every flag must be false for a terminal state.
Input: board = [[0,0],[0,0]], player = 1, seen_positions = [[[0,0],[0,0]]], consecutive_passes = 0, move_count = 0
Output: [True, True, True, True, True]
Explanation: Every empty intersection and the final pass action are legal.
Input: board = [[-1,0,-1],[0,-1,0],[-1,0,-1]], player = 1, seen_positions = [[[-1,0,-1],[0,-1,0],[-1,0,-1]]], consecutive_passes = 0, move_count = 4
Output: [False, False, False, False, False, False, False, False, False, True]
Input: board = [[1,0],[0,-1]], player = 1, seen_positions = [[[1,0],[0,-1]]], consecutive_passes = 2, move_count = 4
Output: [False, False, False, False, False]
divmod(action, board_size) gives the row and column.
A group-and-liberties helper can serve both capture and suicide checks.
np.array_equal compares a candidate board with one seen position.
Accepts: array
Accepts: number
Accepts: array
Accepts: number
Accepts: number
Determine which Go actions are legal. The board uses 0 for empty, 1 for Black, and -1 for White. On a board with side length n, intersection actions are numbered in row-major order from 0 to n squared minus one; action n squared means pass.
A group contains same-colour stones connected horizontally or vertically. Its liberties are adjacent empty intersections. A placement must be on an empty point. Adjacent opposing groups with no liberties are captured; the played stone's group must have a liberty after those captures. The resulting board must not match any supplied seen position, which is the positional-superko rule.
Pass is legal in every nonterminal state. A state is terminal after at least two consecutive passes or at least twice the board area in played actions.
Return a NumPy Boolean array of length n squared plus one, with one flag per intersection followed by pass. Every flag must be false for a terminal state.
Input: board = [[0,0],[0,0]], player = 1, seen_positions = [[[0,0],[0,0]]], consecutive_passes = 0, move_count = 0
Output: [True, True, True, True, True]
Explanation: Every empty intersection and the final pass action are legal.
Input: board = [[-1,0,-1],[0,-1,0],[-1,0,-1]], player = 1, seen_positions = [[[-1,0,-1],[0,-1,0],[-1,0,-1]]], consecutive_passes = 0, move_count = 4
Output: [False, False, False, False, False, False, False, False, False, True]
Input: board = [[1,0],[0,-1]], player = 1, seen_positions = [[[1,0],[0,-1]]], consecutive_passes = 2, move_count = 4
Output: [False, False, False, False, False]
divmod(action, board_size) gives the row and column.
A group-and-liberties helper can serve both capture and suicide checks.
np.array_equal compares a candidate board with one seen position.
Accepts: array
Accepts: number
Accepts: array
Accepts: number
Accepts: number