Encode the current board and up to seven earlier boards from the current player's perspective. History is a newest-first list of PyTorch tensors, with 0 for empty, 1 for Black, and -1 for White.
S=[X0,Y0,X1,Y1,…,X7,Y7,C]Here, X and Y at history step t mark the current player's and opponent's stones, respectively. C contains ones when Black is to play or zeros when White is to play. Each stone plane contains ones at matching intersections and zeros elsewhere; missing history steps contribute two zero planes. The same current-player perspective applies to every history step.
Return S as a PyTorch float32 tensor of shape (17, board size, board size) on the same device as the input tensors.
Input: history = [[[1,0],[-1,1]]], to_play = 1
Output: [[[1,0],[0,1]],[[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,0],[0,0]],[[1,1],[1,1]]]
Explanation: The first two planes encode Black and White, the missing history planes are zero, and the final plane marks Black to play.
Input: history = [[[1,-1],[0,-1]]], to_play = -1
Output: 32-bit floating-point tensor with shape (17,2,2)
Input: history = [[[1,-1,0],[0,1,0],[0,0,-1]],[[1,-1,0],[0,0,0],[0,0,-1]]], to_play = 1
Output: 32-bit floating-point tensor with shape (17,3,3)
Tensor equality produces a Boolean plane; .float() converts it to float32.
torch.zeros can create missing planes on the input device.
torch.stack combines the planes along a new leading dimension.
Accepts: array
Accepts: number
Encode the current board and up to seven earlier boards from the current player's perspective. History is a newest-first list of PyTorch tensors, with 0 for empty, 1 for Black, and -1 for White.
S=[X0,Y0,X1,Y1,…,X7,Y7,C]Here, X and Y at history step t mark the current player's and opponent's stones, respectively. C contains ones when Black is to play or zeros when White is to play. Each stone plane contains ones at matching intersections and zeros elsewhere; missing history steps contribute two zero planes. The same current-player perspective applies to every history step.
Return S as a PyTorch float32 tensor of shape (17, board size, board size) on the same device as the input tensors.
Input: history = [[[1,0],[-1,1]]], to_play = 1
Output: [[[1,0],[0,1]],[[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,0],[0,0]],[[1,1],[1,1]]]
Explanation: The first two planes encode Black and White, the missing history planes are zero, and the final plane marks Black to play.
Input: history = [[[1,-1],[0,-1]]], to_play = -1
Output: 32-bit floating-point tensor with shape (17,2,2)
Input: history = [[[1,-1,0],[0,1,0],[0,0,-1]],[[1,-1,0],[0,0,0],[0,0,-1]]], to_play = 1
Output: 32-bit floating-point tensor with shape (17,3,3)
Tensor equality produces a Boolean plane; .float() converts it to float32.
torch.zeros can create missing planes on the input device.
torch.stack combines the planes along a new leading dimension.
Accepts: array
Accepts: number