Sample training records from the most recent window_size self-play games. Games are ordered oldest to newest, with positions ordered within each game. Each record is a dictionary containing state, policy, and value; preserve these contents without interpreting them.
The eligible pool contains positions from the last window_size games, or all games if fewer are available, in game and position order. Supplied zero-based position_indices select from that pool in their given order, including repeated draws. Do not generate new indices. Return a tuple containing a list of independent deep copies of the selected records and the eligible position count as a Python integer.
Input: games=[[{"state": "s0", "policy": [1, 0], "value": 1}, {"state": "s1", "policy": [0, 1], "value": -1}], [{"state": "s2", "policy": [0.5, 0.5], "value": 0}]], window_size=2, position_indices=[0, 2, 0]
Output: ([{"state": "s0", "policy": [1, 0], "value": 1}, {"state": "s2", "policy": [0.5, 0.5], "value": 0}, {"state": "s0", "policy": [1, 0], "value": 1}], 3)
Explanation: All three positions are eligible, and the repeated index creates a second independent copy of the first record.
Input: games=[[{"state": "old", "policy": [1], "value": -1}], [{"state": "new", "policy": [1], "value": 1}]], window_size=1, position_indices=[0]
Output: ([{"state": "new", "policy": [1], "value": 1}], 1)
Input: games=[[], [{"state": [], "policy": [], "value": 0}, {"state": [1], "policy": [1], "value": 1}]], window_size=5, position_indices=[]
Output: ([], 2)
Negative slicing can select the recent game window.
A nested loop keeps game order and position order intact.
copy.deepcopy each selected record separately to isolate repeated draws.
Accepts: array
Accepts: number
Accepts: array
Sample training records from the most recent window_size self-play games. Games are ordered oldest to newest, with positions ordered within each game. Each record is a dictionary containing state, policy, and value; preserve these contents without interpreting them.
The eligible pool contains positions from the last window_size games, or all games if fewer are available, in game and position order. Supplied zero-based position_indices select from that pool in their given order, including repeated draws. Do not generate new indices. Return a tuple containing a list of independent deep copies of the selected records and the eligible position count as a Python integer.
Input: games=[[{"state": "s0", "policy": [1, 0], "value": 1}, {"state": "s1", "policy": [0, 1], "value": -1}], [{"state": "s2", "policy": [0.5, 0.5], "value": 0}]], window_size=2, position_indices=[0, 2, 0]
Output: ([{"state": "s0", "policy": [1, 0], "value": 1}, {"state": "s2", "policy": [0.5, 0.5], "value": 0}, {"state": "s0", "policy": [1, 0], "value": 1}], 3)
Explanation: All three positions are eligible, and the repeated index creates a second independent copy of the first record.
Input: games=[[{"state": "old", "policy": [1], "value": -1}], [{"state": "new", "policy": [1], "value": 1}]], window_size=1, position_indices=[0]
Output: ([{"state": "new", "policy": [1], "value": 1}], 1)
Input: games=[[], [{"state": [], "policy": [], "value": 0}, {"state": [1], "policy": [1], "value": 1}]], window_size=5, position_indices=[]
Output: ([], 2)
Negative slicing can select the recent game window.
A nested loop keeps game order and position order intact.
copy.deepcopy each selected record separately to isolate repeated draws.
Accepts: array
Accepts: number
Accepts: array