+
+def seq2episodes(seq, height, width):
+ seq = seq.reshape(seq.size(0), -1, height * width + 2)
+ states = seq[:, :, : height * width] - first_state_code
+ states = states.reshape(states.size(0), states.size(1), height, width)
+ actions = seq[:, :, height * width] - first_actions_code
+ rewards = seq[:, :, height * width + 1] - first_rewards_code - 1
+ return states, actions, rewards
+
+
+######################################################################
+
+
+def episodes2str(states, actions, rewards, unicode=False, ansi_colors=False):
+ if unicode:
+ symbols = " █@$"
+ # vert, hori, cross, thin_hori = "║", "═", "╬", "─"
+ vert, hori, cross, thin_hori = "┃", "━", "╋", "─"
+ else:
+ symbols = " #@$"
+ vert, hori, cross, thin_hori = "|", "-", "+", "-"
+
+ hline = (cross + hori * states.size(-1)) * states.size(1) + cross + "\n"