TensorTonic
Study Plans
Study Plan
Find a Go Group and Its Liberties
Reinforcement LearningData Processing
Easy

Find the same-colour stones connected to the occupied starting point through horizontal or vertical neighbours. A liberty is an empty intersection adjacent to any stone in that group; shared liberties count once. The board uses 0 for empty, 1 for Black, and -1 for White.

Return a two-item tuple containing the group coordinate list and the liberty coordinate list. Each coordinate is an integer row-column pair; lists or tuples are accepted for individual pairs. Sort both lists by row, then column.

Loading visualization...

Examples

Input: board = [[1,1,0],[0,1,0],[-1,0,0]], row = 0, col = 0

Output: ([[0,0],[0,1],[1,1]], [[0,2],[1,0],[1,2],[2,1]])

Explanation: The three connected Black stones share four distinct liberties.

Input: board = [[-1,0],[0,0]], row = 0, col = 0

Output: ([[0,0]], [[0,1],[1,0]])

Input: board = [[-1,1,-1],[1,1,1],[-1,1,-1]], row = 1, col = 1

Output: ([[0,1],[1,0],[1,1],[1,2],[2,1]], [])

Hint 1

A set of row-column tuples prevents duplicate coordinates.

Hint 2

Use a stack with pop() to visit connected stones.

Hint 3

sorted() orders coordinate tuples by row, then column.

Requirements

  • Use NumPy.
  • Include each group coordinate and liberty exactly once.
  • Preserve the input board.

Constraints

  • The board is a nonempty square nested Python list of integers.
  • Board values are -1, 0, or 1.
  • Row and col are valid zero-based integer indices identifying a stone.
Try Similar Problems
Score a Terminal Position with Tromp-Taylor RulesMediumApply a Go Action with Captures and RepetitionHardBuild the Legal Go Action MaskHardSample a Recent Self-Play Replay BatchEasyApply a Dihedral Go SymmetryMediumEncode AlphaGo Zero Board HistoryMediumCanonicalize Pairwise Preference DataMediumInitialize Legal MCTS Edge StatisticsEasyExperience Replay BufferEasyNormalized DifferenceEasyEpsilon-Greedy Action SelectionEasyDouble DQN TargetEasy

Accepts: array

Accepts: number

Accepts: number

You must run your code first.

Find a Go Group and Its Liberties

Reinforcement LearningData Processing
Easy

Find the same-colour stones connected to the occupied starting point through horizontal or vertical neighbours. A liberty is an empty intersection adjacent to any stone in that group; shared liberties count once. The board uses 0 for empty, 1 for Black, and -1 for White.

Return a two-item tuple containing the group coordinate list and the liberty coordinate list. Each coordinate is an integer row-column pair; lists or tuples are accepted for individual pairs. Sort both lists by row, then column.

Loading visualization...

Examples

Input: board = [[1,1,0],[0,1,0],[-1,0,0]], row = 0, col = 0

Output: ([[0,0],[0,1],[1,1]], [[0,2],[1,0],[1,2],[2,1]])

Explanation: The three connected Black stones share four distinct liberties.

Input: board = [[-1,0],[0,0]], row = 0, col = 0

Output: ([[0,0]], [[0,1],[1,0]])

Input: board = [[-1,1,-1],[1,1,1],[-1,1,-1]], row = 1, col = 1

Output: ([[0,1],[1,0],[1,1],[1,2],[2,1]], [])

Hint 1

A set of row-column tuples prevents duplicate coordinates.

Hint 2

Use a stack with pop() to visit connected stones.

Hint 3

sorted() orders coordinate tuples by row, then column.

Requirements

  • Use NumPy.
  • Include each group coordinate and liberty exactly once.
  • Preserve the input board.

Constraints

  • The board is a nonempty square nested Python list of integers.
  • Board values are -1, 0, or 1.
  • Row and col are valid zero-based integer indices identifying a stone.
Try Similar Problems
Score a Terminal Position with Tromp-Taylor RulesMediumApply a Go Action with Captures and RepetitionHardBuild the Legal Go Action MaskHardSample a Recent Self-Play Replay BatchEasyApply a Dihedral Go SymmetryMediumEncode AlphaGo Zero Board HistoryMediumCanonicalize Pairwise Preference DataMediumInitialize Legal MCTS Edge StatisticsEasyExperience Replay BufferEasyNormalized DifferenceEasyEpsilon-Greedy Action SelectionEasyDouble DQN TargetEasy

Accepts: array

Accepts: number

Accepts: number

You must run your code first.