in gym/gym/envs/board_game/hex.py [0:0]
def _render(self, mode='human', close=False):
if close:
return
board = self.state
outfile = StringIO() if mode == 'ansi' else sys.stdout
outfile.write(' ' * 5)
for j in range(board.shape[1]):
outfile.write(' ' + str(j + 1) + ' | ')
outfile.write('\n')
outfile.write(' ' * 5)
outfile.write('-' * (board.shape[1] * 6 - 1))
outfile.write('\n')
for i in range(board.shape[1]):
outfile.write(' ' * (2 + i * 3) + str(i + 1) + ' |')
for j in range(board.shape[1]):
if board[2, i, j] == 1:
outfile.write(' O ')
elif board[0, i, j] == 1:
outfile.write(' B ')
else:
outfile.write(' W ')
outfile.write('|')
outfile.write('\n')
outfile.write(' ' * (i * 3 + 1))
outfile.write('-' * (board.shape[1] * 7 - 1))
outfile.write('\n')
if mode != 'human':
return outfile